From fa796b5331b2d17c3008df8829e30ded129ebc40 Mon Sep 17 00:00:00 2001 From: ktkk Date: Mon, 8 Dec 2025 16:25:15 +0000 Subject: [PATCH 01/17] WIP: implement part 1 --- src/days/day08.zig | 139 +++++- src/days/input/day08.txt | 1000 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 1137 insertions(+), 2 deletions(-) create mode 100755 src/days/input/day08.txt diff --git a/src/days/day08.zig b/src/days/day08.zig index 20383ea..89082c4 100644 --- a/src/days/day08.zig +++ b/src/days/day08.zig @@ -1,7 +1,142 @@ const std = @import("std"); -pub const title = "Day 08"; +pub const title = "Day 08: Playground"; -pub fn run(_: std.mem.Allocator) !void { +pub fn run(allocator: std.mem.Allocator) !void { + //const input = @embedFile("./input/day08.txt"); + const input = + \\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 + ; + + var lines = std.mem.tokenizeScalar(u8, input, '\n'); + + var junction_boxes: std.ArrayList(JunctionBox) = .empty; + defer junction_boxes.deinit(allocator); + + var junction_box_index: usize = 0; + while (lines.next()) |line| { + defer junction_box_index += 1; + + var coordinates = std.mem.tokenizeScalar(u8, line, ','); + const x = blk: { + const s = coordinates.next() orelse continue; + break :blk try std.fmt.parseUnsigned(u32, s, 10); + }; + const y = blk: { + const s = coordinates.next() orelse continue; + break :blk try std.fmt.parseUnsigned(u32, s, 10); + }; + const z = blk: { + const s = coordinates.next() orelse continue; + break :blk try std.fmt.parseUnsigned(u32, s, 10); + }; + const junction_box = JunctionBox{ + .index = junction_box_index, + .position = .{ .x = x, .y = y, .z = z }, + }; + try junction_boxes.append(allocator, junction_box); + } + + var network_id: usize = 0; + while (true) { + var shortest_distance: ?u32 = null; + var a: ?*JunctionBox = null; + var b: ?*JunctionBox = null; + for (junction_boxes.items, 0..) |*junction_box, i| { + for (junction_boxes.items[i + 1..]) |*other_junction_box| { + if (junction_box.network != null and other_junction_box.network != null) { + if (junction_box.network == other_junction_box.network) continue; + } + + const distance = junction_box.position.distance(other_junction_box.position); + if (shortest_distance == null or distance < shortest_distance.?) { + shortest_distance = distance; + a = junction_box; + b = other_junction_box; + } + } + } + + std.debug.print("shortest distance = {?d} between {?f} and {?f}\n", .{shortest_distance, a, b}); + + if (a != null and b != null) { + if (a.?.network != null and b.?.network == null) { + std.debug.print("assigning network {?d} to {?f}\n", .{a.?.network, b}); + b.?.network = a.?.network; + } else if (b.?.network != null and a.?.network == null) { + std.debug.print("assigning network {?d} to {?f}\n", .{b.?.network, a}); + a.?.network = b.?.network; + } else { + std.debug.print("assigning network {d} to {?f} and {?f}\n", .{network_id, a, b}); + a.?.network = network_id; + b.?.network = network_id; + network_id += 1; + } + } else if (a) |junction_box| { + junction_box.network = network_id; + network_id += 1; + } else if (b) |junction_box| { + junction_box.network = network_id; + network_id += 1; + } + + if (network_id >= 20) { + break; + } + } + + for (junction_boxes.items) |junction_box| { + std.debug.print("{f}\n", .{junction_box}); + } } +const JunctionBox = struct { + index: usize, + network: ?usize = null, + position: Position, + + const Self = @This(); + + pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { + try w.print("{d} in network {?d} at {f}", .{self.index, self.network, self.position}); + } +}; + +const Position = struct { + x: u32, + y: u32, + z: u32, + + const Self = @This(); + + pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { + try w.print("{d}, {d}, {d}", .{self.x, self.y, self.z}); + } + + pub fn distance(self: Self, other: Self) u32 { + const xds = std.math.pow(u32, @max(self.x, other.x) - @min(self.x, other.x), 2); + const yds = std.math.pow(u32, @max(self.y, other.y) - @min(self.y, other.y), 2); + const zds = std.math.pow(u32, @max(self.z, other.z) - @min(self.z, other.z), 2); + return std.math.sqrt(xds + yds + zds); + } +}; + diff --git a/src/days/input/day08.txt b/src/days/input/day08.txt new file mode 100755 index 0000000..300a2da --- /dev/null +++ b/src/days/input/day08.txt @@ -0,0 +1,1000 @@ +20777,62942,19723 +42972,30609,62475 +56049,10549,19554 +71897,99081,70264 +94818,64824,2168 +61615,9572,66230 +87804,95946,40652 +50039,22696,52204 +62624,81824,35726 +53922,25473,10598 +85151,46272,56496 +93671,32179,19870 +33557,66547,4748 +96608,71887,9647 +81328,88872,43186 +81409,3653,17891 +99590,74944,48513 +69788,9774,56998 +81615,32949,66471 +83841,55524,90770 +88298,80792,44136 +96882,90907,68964 +68114,81587,28190 +24634,19966,88922 +20995,39937,49956 +22682,74304,96721 +1018,50322,92118 +73025,53878,28344 +98732,30236,54656 +38044,64456,11345 +83390,61969,69925 +51395,90842,58661 +65464,21203,85371 +65026,37989,7336 +14774,44620,67643 +64334,28201,18209 +77983,49947,59417 +35920,77629,88037 +78768,43166,86672 +65620,71723,34250 +99110,5678,16423 +96278,72417,12859 +21346,3739,59110 +38511,12327,2149 +12763,79788,11320 +2776,54840,16469 +58582,23762,79756 +1830,96420,44680 +86670,90335,53119 +68762,49152,86134 +56842,1546,91626 +90630,33507,86800 +16393,73883,32320 +85188,81438,79571 +5721,21646,39622 +34111,94995,61900 +19290,81642,32311 +43545,17970,23463 +28076,83571,40251 +45580,28547,2271 +91974,65147,81738 +46759,31788,85986 +64769,9339,22220 +97285,97751,23413 +42799,76343,88561 +79112,62161,15992 +29929,42204,82298 +16830,61276,32776 +91578,91729,38794 +37806,2172,80147 +50042,96637,18217 +68823,5743,26956 +32360,46472,28599 +6778,86907,67503 +94500,14784,51360 +74664,18113,65746 +57843,95426,85808 +82616,30140,21061 +42614,83823,28641 +41380,25069,59362 +83315,9429,82747 +77328,78465,67673 +52031,32595,97921 +76088,86256,89478 +6706,39747,26674 +12557,87121,62743 +33950,45552,23583 +31585,26032,22578 +33870,6206,65850 +53361,25519,23751 +63020,52785,47884 +79016,43804,12542 +54255,67245,70184 +80457,58165,67836 +64056,1687,95408 +20790,98838,30045 +2883,37548,36106 +71073,19539,81820 +7182,18597,58592 +18143,12621,80530 +6780,22126,49765 +8239,71596,68788 +89281,86941,24710 +7959,35086,66329 +15634,18831,93127 +3954,48354,31392 +88059,16066,2161 +59077,43286,27628 +21105,4829,39836 +45571,12183,58321 +98974,46125,55807 +73733,68623,31838 +1836,9878,6191 +28912,66389,84074 +32135,27457,57920 +70808,16753,21585 +2139,380,64759 +52646,44071,42531 +81166,56071,29109 +7936,60700,32872 +83461,55707,10252 +22791,66103,48388 +28139,23234,69744 +64533,59559,41313 +36330,31813,78802 +64772,84324,26022 +15287,9089,40021 +40346,12414,24996 +25145,38364,50767 +4063,88207,88534 +66071,85200,19824 +39132,78541,66239 +63306,33774,24944 +50475,4285,18871 +44608,85769,88303 +36601,32502,74868 +96949,88530,98652 +80653,93039,55014 +96075,13752,88117 +50233,26907,55857 +63491,19657,56626 +38204,94316,60019 +52712,97473,47904 +77364,80440,72126 +98238,38518,93979 +70463,72265,9473 +34797,41760,6263 +80876,16414,56630 +86829,28219,29719 +59473,7654,40839 +36732,90610,25290 +29690,43542,98861 +12174,15514,11030 +26038,8654,34985 +1316,56659,76172 +37147,90069,91445 +67014,82602,41934 +38396,1108,86150 +35430,76040,84142 +44545,92419,49423 +3041,75650,68326 +19194,92179,26233 +65941,20630,6806 +21991,66345,64278 +56699,76018,13880 +49103,14347,7898 +32416,77461,96050 +73979,91701,87941 +33162,65456,35080 +25092,73070,91602 +43363,76598,27823 +54526,59399,49533 +82193,14090,69671 +63362,75234,88959 +13866,82616,30404 +95246,22241,34966 +62582,67694,10184 +88298,76639,71228 +56621,34825,65861 +755,70077,31711 +50969,93934,85669 +21032,86397,81222 +16049,30459,22241 +57410,97401,87987 +2991,43364,71500 +55844,20872,81334 +40297,51418,18081 +64445,29710,16641 +52079,84560,33464 +75555,37764,13111 +50855,76099,54092 +28581,29067,3364 +27557,20797,11607 +24071,65720,35964 +40060,35958,28461 +54263,62787,50429 +68179,91959,47566 +95743,1195,97146 +47143,43443,57168 +18877,19098,99299 +90374,6317,91524 +67293,82919,72263 +1371,60668,64989 +94896,15560,56622 +68340,45560,99588 +43458,96683,7911 +92395,2840,78314 +85571,18839,81053 +83155,98861,56152 +96823,66878,15004 +22655,88225,10421 +85919,75426,35746 +73196,30232,58809 +94558,74730,64942 +2548,97914,72147 +92606,13033,40386 +52601,83217,64208 +38883,10808,59803 +77658,89272,15747 +32604,80713,64467 +78230,10074,64041 +27615,36584,3633 +88245,91926,62670 +96731,45164,41549 +19567,53197,91442 +19215,47753,32807 +87956,84095,23770 +77615,91981,84062 +87077,46515,23634 +71379,12943,50101 +22978,9547,75373 +67042,8760,75738 +80678,77134,68711 +931,3534,97128 +49750,15683,50397 +51736,64507,79680 +44757,4005,99188 +77903,42517,33301 +52581,14943,69471 +13484,83578,44925 +34487,63451,16219 +40160,27865,23352 +89072,43498,13289 +35266,26876,23110 +70569,61663,14212 +73432,34540,69291 +16624,91305,390 +3159,96887,24366 +57549,13875,31802 +1540,61011,22731 +36473,38811,21433 +79678,32850,82280 +72159,8729,61485 +33834,63857,38616 +79967,70714,14997 +80849,38160,50855 +60999,66004,84608 +12382,56344,57469 +75952,63319,85023 +81372,12759,90720 +75847,95491,62262 +35330,33634,48167 +97532,6229,26292 +82128,50560,90895 +85225,25491,55824 +30550,14028,92512 +33624,23026,72683 +26055,6603,19470 +33816,39635,56740 +44683,49062,23683 +56860,80621,30410 +33824,64478,59476 +39188,70994,55349 +56652,87772,37816 +29059,8984,32632 +33283,13908,2660 +66116,50473,78343 +35723,75571,18189 +61541,7898,16747 +77260,27128,86032 +61721,82361,27360 +36079,5260,48857 +16691,65524,5833 +26148,45066,36027 +64679,30588,84415 +51255,7156,45227 +33888,5007,81917 +24863,17881,59394 +74842,94135,38697 +70762,93268,6395 +95898,64937,92422 +30826,5482,95081 +27657,45685,82784 +70866,44299,53644 +27463,91670,89956 +70136,21530,28186 +13620,12547,21815 +94185,20952,84090 +66565,15373,87947 +74914,87307,6455 +5356,19219,7447 +96063,76823,52957 +49131,16229,24815 +14898,61068,87121 +53611,54521,18754 +56273,68915,34555 +51898,85814,82943 +1989,83862,52142 +23965,8438,57263 +24374,84642,75027 +96276,4695,56676 +55867,67827,43039 +15153,72072,44176 +17215,97870,80751 +2210,98505,18346 +52738,79073,91945 +9935,52981,19068 +53739,8955,18756 +17653,88911,90993 +85305,89978,27243 +3970,14555,53955 +61089,28643,90394 +32117,15093,9992 +80304,98311,54321 +66552,55981,50998 +37468,7839,69958 +6047,87776,88373 +7380,10417,2885 +49642,54820,71159 +11369,55142,36097 +29276,27980,98195 +69129,38003,70200 +54680,60880,3118 +98448,93512,18364 +27500,92931,34548 +53255,61937,7602 +27351,63219,83443 +60914,93676,3475 +5268,63037,42876 +12637,19182,8004 +2050,24739,545 +9028,53697,7803 +85319,47129,2676 +93674,91377,72495 +94166,55693,84992 +19052,25585,3269 +38660,3804,71181 +75500,34896,11157 +9689,60810,9326 +50137,86571,54240 +7414,99696,85068 +97847,35074,68818 +38806,68813,92067 +27616,15653,71787 +86544,60712,92831 +21010,82924,41860 +40206,29480,47185 +79715,27738,49176 +32709,79060,78171 +71961,25447,53349 +33308,25736,14069 +6527,86143,6532 +13968,31596,28606 +23230,93758,96658 +60635,97412,90047 +66372,18403,33246 +56487,37255,83249 +29480,52983,12421 +86559,52363,11742 +57567,95520,80878 +10731,31886,49404 +7182,79104,80579 +72396,59840,60886 +79494,56678,76496 +75431,95645,35718 +98600,59109,42999 +32844,82872,20692 +82439,12034,13016 +31887,14414,97290 +68159,38365,7141 +92693,30378,69946 +71605,88440,37860 +51005,54787,98408 +59849,33611,56892 +43805,57859,61895 +57997,85341,30060 +12077,49593,55694 +13616,69688,31502 +55245,46639,4822 +42828,30608,96763 +84503,24421,48327 +28771,35284,51373 +29243,66938,1161 +57766,4214,68382 +64444,97022,53623 +47698,38061,23339 +73769,18115,45095 +40632,78017,54566 +68684,82023,52528 +55010,46364,55934 +91105,20501,56751 +14402,85074,85634 +82434,69184,28311 +79520,55813,44685 +58984,55386,99430 +20855,25236,92728 +49349,80169,66768 +99789,10097,40823 +15815,52674,88431 +82699,64779,28831 +17134,66905,32126 +81728,30568,16109 +99131,66717,32993 +78058,36707,48095 +95581,94142,433 +78933,86408,58239 +32769,59114,32169 +87062,71491,6041 +4121,54630,52885 +55643,32287,31971 +5144,89424,70005 +44842,22551,23631 +39548,31809,72973 +17995,93203,81694 +31391,59367,72568 +21059,19907,46871 +61895,41320,21886 +73455,24484,22376 +84564,39129,19970 +60564,23142,95202 +5863,17684,40715 +59955,80155,13069 +15541,43916,69776 +9725,21293,8860 +79013,39898,11015 +66482,95043,55586 +43189,10113,86789 +20210,73259,1679 +6451,12473,98376 +94130,8184,40237 +82380,20786,79245 +47749,14938,93286 +48936,94692,69228 +11390,9255,30267 +20143,44453,77474 +33763,6163,16641 +29704,38034,57006 +37567,80915,50936 +42989,15808,21138 +346,92185,19497 +33584,91798,21826 +40714,6482,31575 +55428,69363,95430 +2413,45787,69277 +97138,94454,40634 +54058,4108,71516 +79808,31232,22706 +6380,5643,29972 +98633,25322,21487 +21749,52309,43718 +80458,57166,71001 +49537,94026,14211 +71945,38703,93689 +3920,58347,59687 +23839,37703,7115 +38694,68819,87704 +98605,31131,40370 +86800,71778,49770 +55071,20237,36268 +20364,86426,66351 +21290,97204,67964 +91968,91494,65090 +76621,99377,15202 +61711,27948,39642 +60636,72192,43962 +42424,2169,92177 +2079,89495,99103 +89879,70203,59321 +23662,53173,73295 +58217,48592,13159 +4257,1779,95800 +38641,84597,23969 +9809,90228,34775 +33156,69323,71941 +31349,50555,29119 +81458,97974,10406 +86572,16840,3878 +59270,62993,72347 +69808,8393,51354 +44028,14726,94986 +7598,57171,12819 +30688,2594,33413 +80115,25752,32595 +90985,22291,1400 +35984,43689,63607 +48424,37979,54251 +43787,73718,49117 +47598,31399,46824 +60662,86528,14698 +22624,95104,13798 +13385,63446,93608 +23537,16143,11505 +17261,14405,11792 +910,44432,15341 +8367,35498,3172 +51056,50153,65163 +52684,12473,62729 +47909,40289,21716 +9329,98872,5447 +81552,96421,70358 +77190,95478,54439 +30463,39406,52259 +62286,72128,94730 +23272,16830,81978 +94222,3495,45379 +79700,69526,88612 +58559,37208,86799 +68133,70392,43558 +68585,94486,13403 +70468,8985,72994 +29596,46101,48330 +89934,68002,75962 +12239,33467,99683 +81854,43902,63047 +19544,17836,31993 +90712,27669,79142 +25326,65897,22217 +41829,21697,13411 +30988,61045,65973 +91257,13719,50868 +11958,85759,74958 +62647,15738,91054 +95202,48972,83718 +68761,62011,31487 +96427,12071,23308 +545,46079,52752 +91352,38580,40112 +25743,61293,35406 +39148,15778,25222 +18524,72485,45769 +27820,53859,40217 +64552,28429,38914 +2817,59748,76518 +50624,37615,62634 +31572,71662,19626 +49246,37261,81654 +50701,43865,5144 +1820,6956,36432 +50943,43653,16810 +68218,21687,63089 +89959,74831,33537 +22534,36311,1913 +26194,33476,90499 +96758,12371,94103 +65537,93974,31189 +59371,23542,40633 +87795,27950,73930 +77379,2194,1859 +93362,7676,86793 +53797,36604,44509 +1762,15154,54918 +39327,91596,98517 +16393,33840,15802 +73807,90221,64311 +45995,91553,506 +17638,94624,62688 +66661,96045,98861 +2946,31725,48821 +80425,97686,58707 +55983,9595,88038 +96027,80587,41535 +28001,5653,2526 +52994,43276,31220 +98541,6588,18567 +65502,73700,28683 +34874,52620,70122 +88286,1850,79003 +86021,18991,40513 +55698,2984,92090 +35025,26256,88702 +18056,8798,26168 +98132,80375,89467 +6242,91510,83393 +19028,46597,1842 +97383,61226,74757 +79640,45131,43498 +95943,29878,1987 +36174,8019,23171 +16528,6113,33412 +80990,68808,69483 +70752,81831,86579 +13498,78840,23094 +32295,9143,23072 +71309,51992,16462 +71597,93252,65010 +6011,46592,42224 +45847,20345,50225 +70256,58104,58849 +69592,98365,98556 +39041,58463,36852 +76694,14384,23433 +46922,23019,79378 +49756,47650,95798 +79628,68043,30131 +50368,50065,32000 +58259,83494,6539 +82956,35190,55312 +12543,67052,51379 +87144,77545,32194 +17223,778,29876 +15353,16390,95817 +54555,76256,98723 +424,24183,95086 +397,97427,53765 +22517,28127,44549 +23149,7360,50737 +22669,73921,76532 +90042,60042,61787 +64202,11641,69468 +36642,81087,60139 +78219,6908,44519 +21027,31475,93993 +7229,88823,65753 +88624,94643,77349 +12008,20719,92120 +79546,33378,55773 +84801,10961,90918 +36344,2250,99996 +74628,20229,30484 +99626,25996,95851 +37289,27351,2626 +18920,88676,13632 +12806,46701,79922 +82445,46745,1688 +42850,62351,97291 +74648,39964,51896 +42979,48188,97753 +41189,33979,51196 +37301,32127,1921 +27684,15333,45494 +9293,51433,17522 +54693,66492,41795 +36430,26328,4290 +32600,96504,68448 +77912,32250,49469 +11926,54002,50947 +85851,60802,52854 +93111,86931,8191 +71642,47272,59684 +97721,37353,176 +53187,21801,45061 +49968,85202,50070 +43733,58949,13139 +20245,80143,28520 +54286,52532,95692 +77041,113,54581 +61253,80073,21527 +10581,3628,86818 +33592,22729,22340 +47053,75253,30837 +67405,79806,72616 +42434,620,56997 +65597,69059,47230 +11602,24274,55779 +83641,52732,34927 +26504,54576,37376 +8947,91923,30505 +36429,89078,15061 +45994,65623,19063 +23291,25054,12216 +95947,40224,59134 +44097,44629,13016 +588,1619,46842 +14747,63513,17094 +33802,22275,63578 +1313,17514,36510 +90125,76120,39931 +92433,56778,13917 +81903,32509,73000 +92531,10309,10594 +78442,62320,87770 +89311,77105,3237 +5716,66470,49900 +76215,79595,53725 +45317,25305,11402 +60940,89815,95914 +46092,53941,96076 +8260,37391,32189 +10215,72942,77135 +61014,42921,93853 +8795,24067,96724 +59541,38098,83306 +87241,42289,15294 +8327,62419,56433 +1132,23026,35422 +81510,64930,84905 +18116,21021,38580 +51831,13368,19614 +58854,22857,71871 +26386,36277,86116 +71849,4642,72016 +68583,63965,17428 +38524,18590,59975 +11048,56248,44635 +67360,17739,84532 +22673,89975,38725 +1505,60741,93183 +48869,8261,11607 +76503,40845,91444 +58630,77179,39733 +76429,70129,2940 +15527,13367,46225 +34328,81452,49442 +38007,58147,28163 +43632,40657,69646 +28674,92256,83838 +77097,84850,23529 +18858,37227,34880 +32647,32219,61821 +21634,12534,69567 +46688,36206,62812 +97703,55344,9080 +56005,51197,26453 +66007,6990,34957 +90595,97253,32561 +86297,66677,90670 +32478,36065,38690 +42232,52766,65234 +81120,6138,64408 +93185,36580,62051 +65199,89224,46915 +24113,75617,97545 +82743,67340,88582 +56020,3905,7144 +62169,64267,51406 +99887,29384,80288 +21150,82531,82309 +56548,90725,90994 +63125,45149,67153 +76481,32097,32487 +38440,20703,54640 +1328,52521,61930 +54449,53111,9669 +49013,6182,30037 +71173,85874,99529 +66746,25081,27322 +37768,78212,66838 +8091,97423,25896 +4088,8599,84834 +16628,40689,90322 +79962,80368,63919 +95582,65194,41143 +13052,71321,84903 +35072,85089,80882 +1642,35036,80671 +95556,24542,73885 +69292,84610,33009 +7474,57154,8994 +41995,94344,27913 +80088,98370,76895 +11955,90756,93396 +81383,47145,76933 +45153,71117,98465 +59649,82279,81209 +57044,30718,20849 +8039,23626,83495 +80517,36821,18655 +51750,95799,56822 +40066,94989,52809 +98232,79905,91617 +85490,32859,64143 +17138,73071,52857 +74038,84744,41158 +984,81703,77012 +94841,23301,51936 +58123,4347,86987 +18159,56681,90117 +52152,8228,29842 +33350,61435,12315 +80728,44651,7611 +44393,24856,2729 +14711,27952,36070 +67052,68342,20426 +48409,34064,16317 +97099,24054,51554 +6634,39828,72233 +74598,30885,58450 +39769,70020,13609 +26396,88561,10046 +17888,27138,14140 +97915,61889,54341 +2120,32447,62380 +96122,21270,53865 +61810,80127,74550 +22134,43172,81596 +26474,14749,16776 +16863,21273,77743 +74288,91084,34875 +44589,2212,20518 +26144,98260,29090 +24353,88378,38826 +18295,61145,52792 +6166,76378,41466 +71431,19846,11534 +66660,50446,37461 +78489,48099,16272 +2137,86552,40108 +60432,79114,22965 +50634,14416,51819 +71337,67853,78370 +17376,46623,89161 +47911,49744,56694 +55762,16728,71455 +63647,65178,51242 +29980,3852,53179 +42496,26225,27806 +42607,2739,6198 +2864,50418,35603 +44854,42953,15680 +64441,25076,37761 +85719,5336,26927 +20955,83612,59576 +12036,87722,19591 +66912,36314,37511 +23986,85346,81260 +82711,60544,66303 +9452,2583,73246 +51873,36373,87781 +1017,9117,86548 +14703,74164,4825 +67635,95221,11135 +88006,80517,76496 +68526,6496,75855 +28273,14025,46983 +65541,14149,64205 +77376,31136,37825 +75440,48370,28668 +26008,85212,3434 +40940,23815,57043 +67983,53329,54996 +89442,68335,38423 +33452,57371,37190 +97904,1442,83870 +26981,78999,36937 +4870,96702,17318 +93069,27601,96947 +50799,57987,73311 +26258,51149,7097 +89422,7856,62974 +41291,61518,66798 +67845,95723,18443 +15140,74735,71894 +16491,57317,11366 +805,93872,54351 +67548,22576,81909 +67234,43951,56051 +43192,84886,43099 +94433,22405,16985 +16689,65863,56679 +47882,50442,33166 +8082,44429,28186 +18730,80710,42052 +7154,48970,43501 +92786,50863,40101 +14276,14750,42354 +59610,44402,32900 +66321,29440,35343 +11842,58758,19686 +86375,42113,91156 +84456,76481,27307 +12487,48117,12371 +90714,29316,29528 +94373,17541,88516 +70981,99722,17678 +86189,37350,14478 +36118,46582,56343 +3391,93699,24521 +67707,29367,848 +23056,13591,41596 +68506,18667,99069 +72575,12428,3885 +59949,80468,54803 +91305,12584,63929 +17866,43667,9602 +63508,51080,67311 +57380,57120,61966 +16574,51090,99319 +32185,35403,75406 +45846,98384,11076 +92050,29398,91303 +29816,66469,899 +46644,99953,31409 +29708,17355,97825 +53960,22292,24872 +48367,72657,12647 +19381,49718,89613 +91967,71046,90045 +99694,70738,14898 +12173,51808,67964 +71791,60548,96036 +72673,15673,37390 +30738,11838,10976 +30483,73464,33052 +64006,75717,63412 +44953,16485,79782 +57548,44387,20051 +24395,29447,56444 +12519,61854,10000 +50329,58566,1540 +88571,79007,42792 +15483,81138,67772 +98351,94412,6422 +18026,48853,63854 +89770,65097,22339 +58240,80119,53987 +64206,72169,47821 +13700,49143,23865 +18497,60048,59410 +2314,61182,5732 +42196,41541,66447 +23951,86628,1947 +33338,93299,21115 +7638,2164,44062 +43987,22490,75375 +20853,69392,40766 +25784,84917,94057 +84735,27877,12650 +28415,59780,73757 +92732,11514,66004 +22167,3127,15527 +55375,13763,25418 +61312,10183,74808 +67561,33175,52518 +95559,85684,31949 +31811,21208,19531 +49476,91559,68710 +39712,39185,94833 +52948,10125,4551 +41183,8388,89450 +15354,71712,48189 +6237,83879,28533 +33487,87651,46770 +86581,79868,43002 +49212,94807,6042 +7943,71512,26361 +31857,98286,65008 +12452,17207,91675 +19474,26614,46380 +95090,36404,63062 +32042,15906,44729 +9117,80102,58916 +90870,35796,70572 +11240,89359,75236 +86642,22094,25156 +35558,22739,28788 +86897,95920,3348 +57491,40447,23544 +77554,13497,7770 +52283,86126,480 +67729,16495,63983 +26202,2014,86875 +27035,39844,17507 +87797,70368,60825 +85362,81716,64502 +52686,83672,61900 +16584,67436,57067 +51528,30585,71528 +55568,65486,28975 +11164,49777,16477 +1776,9274,97965 +48804,1871,22628 +4006,76888,74703 +21401,3007,52716 +78258,73464,20159 +3096,60495,13624 +13794,87629,88860 +42769,26015,16236 +40103,82017,32924 +33751,93304,79488 +21564,44610,83725 +59242,66082,95378 +62154,17151,38955 +25117,88117,13461 +84727,84511,30942 +57868,93469,74159 +30779,90034,64698 +78228,58657,83070 +87385,97051,13550 +21022,11127,86967 +32205,33295,35860 +25239,65855,51216 +93179,31615,10990 +43023,55949,30938 +12676,22645,13162 +94984,76400,55312 +72395,82327,98795 +66775,87119,17346 +37618,21354,54595 +42239,10905,88143 +7850,95744,85655 From 47a8eaa38c64cb0eb70a14e429a865429b258143 Mon Sep 17 00:00:00 2001 From: ktkk Date: Mon, 8 Dec 2025 21:29:47 +0000 Subject: [PATCH 02/17] WIP: implement part 1 --- src/days/day08.zig | 96 ++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 55 deletions(-) diff --git a/src/days/day08.zig b/src/days/day08.zig index 89082c4..5f695ee 100644 --- a/src/days/day08.zig +++ b/src/days/day08.zig @@ -51,92 +51,78 @@ pub fn run(allocator: std.mem.Allocator) !void { }; const junction_box = JunctionBox{ .index = junction_box_index, - .position = .{ .x = x, .y = y, .z = z }, + .position = .{ .v = .{ x, y, z } }, }; try junction_boxes.append(allocator, junction_box); } - var network_id: usize = 0; - while (true) { - var shortest_distance: ?u32 = null; - var a: ?*JunctionBox = null; - var b: ?*JunctionBox = null; - for (junction_boxes.items, 0..) |*junction_box, i| { - for (junction_boxes.items[i + 1..]) |*other_junction_box| { - if (junction_box.network != null and other_junction_box.network != null) { - if (junction_box.network == other_junction_box.network) continue; - } + var possible_connections: std.ArrayList(Connection) = .empty; + defer possible_connections.deinit(allocator); + var connection_index: usize = 0; + for (junction_boxes.items, 0..) |junction_box, i| { + for (junction_boxes.items[i + 1..]) |other_junction_box| { + defer connection_index += 1; - const distance = junction_box.position.distance(other_junction_box.position); - if (shortest_distance == null or distance < shortest_distance.?) { - shortest_distance = distance; - a = junction_box; - b = other_junction_box; - } - } - } - - std.debug.print("shortest distance = {?d} between {?f} and {?f}\n", .{shortest_distance, a, b}); - - if (a != null and b != null) { - if (a.?.network != null and b.?.network == null) { - std.debug.print("assigning network {?d} to {?f}\n", .{a.?.network, b}); - b.?.network = a.?.network; - } else if (b.?.network != null and a.?.network == null) { - std.debug.print("assigning network {?d} to {?f}\n", .{b.?.network, a}); - a.?.network = b.?.network; - } else { - std.debug.print("assigning network {d} to {?f} and {?f}\n", .{network_id, a, b}); - a.?.network = network_id; - b.?.network = network_id; - network_id += 1; - } - } else if (a) |junction_box| { - junction_box.network = network_id; - network_id += 1; - } else if (b) |junction_box| { - junction_box.network = network_id; - network_id += 1; - } - - if (network_id >= 20) { - break; + const length = junction_box.position.distance(other_junction_box.position); + const connection = Connection{ + .index = connection_index, + .from = junction_box, + .to = other_junction_box, + .length = length, + }; + try possible_connections.append(allocator, connection); } } for (junction_boxes.items) |junction_box| { std.debug.print("{f}\n", .{junction_box}); } + + for (possible_connections.items) |connection| { + std.debug.print("{f}\n", .{connection}); + } } +const Connection = struct { + index: usize, + from: JunctionBox, + to: JunctionBox, + length: u32, + network: ?usize = null, + + const Self = @This(); + + pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { + try w.print("({d}) {d} to {d}, length = {d}, network = {?d}", .{self.index, self.from.index, self.to.index, self.length, self.network}); + } +}; + const JunctionBox = struct { index: usize, - network: ?usize = null, position: Position, const Self = @This(); pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { - try w.print("{d} in network {?d} at {f}", .{self.index, self.network, self.position}); + try w.print("({d}) {f}", .{self.index, self.position}); } }; const Position = struct { - x: u32, - y: u32, - z: u32, + v: @Vector(3, u32), const Self = @This(); pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { - try w.print("{d}, {d}, {d}", .{self.x, self.y, self.z}); + try w.print("{d}, {d}, {d}", .{self.v[0], self.v[1], self.v[2]}); } pub fn distance(self: Self, other: Self) u32 { - const xds = std.math.pow(u32, @max(self.x, other.x) - @min(self.x, other.x), 2); - const yds = std.math.pow(u32, @max(self.y, other.y) - @min(self.y, other.y), 2); - const zds = std.math.pow(u32, @max(self.z, other.z) - @min(self.z, other.z), 2); - return std.math.sqrt(xds + yds + zds); + const comp = self.v < other.v; + const low = @select(u32, comp, self.v, other.v); + const high = @select(u32, !comp, self.v, other.v); + const diff = high - low; + return std.math.sqrt(@reduce(.Add, diff * diff)); } }; From 3eb2e2d4c180a752ccf687844bb3c958c9ec73a0 Mon Sep 17 00:00:00 2001 From: ktkk Date: Mon, 8 Dec 2025 22:30:23 +0000 Subject: [PATCH 03/17] WIP: implement part 1 --- src/days/day08.zig | 45 +++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/days/day08.zig b/src/days/day08.zig index 5f695ee..87a7c79 100644 --- a/src/days/day08.zig +++ b/src/days/day08.zig @@ -53,6 +53,8 @@ pub fn run(allocator: std.mem.Allocator) !void { .index = junction_box_index, .position = .{ .v = .{ x, y, z } }, }; + std.debug.print("{f}\n", .{junction_box}); + try junction_boxes.append(allocator, junction_box); } @@ -70,16 +72,43 @@ pub fn run(allocator: std.mem.Allocator) !void { .to = other_junction_box, .length = length, }; + std.debug.print("{f}\n", .{connection}); + try possible_connections.append(allocator, connection); } } - for (junction_boxes.items) |junction_box| { - std.debug.print("{f}\n", .{junction_box}); - } + std.mem.sort(Connection, possible_connections.items, {}, struct { + fn f(_: void, lhs: Connection, rhs: Connection) bool { + return lhs.length < rhs.length; + } + }.f); + + var network_id: usize = 0; + for (possible_connections.items, 0..) |*connection, i| { + var connection_network_id = network_id; + for (possible_connections.items) |other_connection| { + if (connection.index == other_connection.index) { + continue; + } + if (other_connection.network == null) { + continue; + } + if (connection.connected(other_connection)) { + connection_network_id = other_connection.network.?; + } + } + + connection.network = connection_network_id; + if (connection_network_id == network_id) { + network_id += 1; + } - for (possible_connections.items) |connection| { std.debug.print("{f}\n", .{connection}); + + if (i >= 10) { + break; + } } } @@ -95,6 +124,14 @@ const Connection = struct { pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { try w.print("({d}) {d} to {d}, length = {d}, network = {?d}", .{self.index, self.from.index, self.to.index, self.length, self.network}); } + + pub fn connected(self: Self, other: Self) bool { + if (self.from.index == other.from.index) return true; + if (self.to.index == other.from.index) return true; + if (self.from.index == other.to.index) return true; + if (self.to.index == other.to.index) return true; + return false; + } }; const JunctionBox = struct { From d1e798bdbf149aad36422aaceeea8a42a08774a8 Mon Sep 17 00:00:00 2001 From: ktkk Date: Tue, 9 Dec 2025 09:17:25 +0000 Subject: [PATCH 04/17] Finish day09, part 1 --- src/days/day09.zig | 88 ++++++- src/days/input/day09.txt | 496 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 582 insertions(+), 2 deletions(-) create mode 100755 src/days/input/day09.txt diff --git a/src/days/day09.zig b/src/days/day09.zig index 5b8cfab..e85cb36 100644 --- a/src/days/day09.zig +++ b/src/days/day09.zig @@ -1,7 +1,91 @@ const std = @import("std"); -pub const title = "Day 09"; +pub const title = "Day 09: Movie Theater"; -pub fn run(_: std.mem.Allocator) !void { +pub fn run(allocator: std.mem.Allocator) !void { + const input = @embedFile("./input/day09.txt"); + //const input = + // \\7,1 + // \\11,1 + // \\11,7 + // \\9,7 + // \\9,5 + // \\2,5 + // \\2,3 + // \\7,3 + // ; + + var lines = std.mem.tokenizeScalar(u8, input, '\n'); + + var tiles: std.ArrayList(Tile) = .empty; + defer tiles.deinit(allocator); + + while (lines.next()) |line| { + var coordinates = std.mem.tokenizeScalar(u8, line, ','); + const x = blk: { + const s = coordinates.next() orelse continue; + break :blk try std.fmt.parseUnsigned(u64, s, 10); + }; + const y = blk: { + const s = coordinates.next() orelse continue; + break :blk try std.fmt.parseUnsigned(u64, s, 10); + }; + try tiles.append(allocator, .{ .x = x, .y = y }); + } + + var largest_area: usize = 0; + var largest_rectangle: Rectangle = undefined; + for (tiles.items, 0..) |first_tile, i| { + for (tiles.items[i + 1..]) |second_tile| { + const rectangle = first_tile.rectangle(second_tile); + const area = rectangle.area(); + if (area > largest_area) { + largest_area = area; + largest_rectangle = rectangle; + } + } + } + + std.debug.print("rectangle = {f}\n", .{largest_rectangle}); + + var buffer: [64]u8 = undefined; + var stdout_writer = std.fs.File.stdout().writer(&buffer); + const stdout = &stdout_writer.interface; + + try stdout.print("{d}\n", .{largest_area}); + + try stdout.flush(); } +const Tile = struct { + x: u64, + y: u64, + + const Self = @This(); + + pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { + try w.print("{d},{d}", .{self.x, self.y}); + } + + pub fn rectangle(self: Self, other_corner: Self) Rectangle { + return .{ .a = self, .b = other_corner }; + } +}; + +const Rectangle = struct { + a: Tile, + b: Tile, + + const Self = @This(); + + pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { + try w.print("{f} to {f}", .{self.a, self.b}); + } + + pub fn area(self: Self) u64 { + const width = @max(self.a.x, self.b.x) - @min(self.a.x, self.b.x) + 1; + const height = @max(self.a.y, self.b.y) - @min(self.a.y, self.b.y) + 1; + return width * height; + } +}; + diff --git a/src/days/input/day09.txt b/src/days/input/day09.txt new file mode 100755 index 0000000..44cac4b --- /dev/null +++ b/src/days/input/day09.txt @@ -0,0 +1,496 @@ +98241,50245 +98241,51464 +98122,51464 +98122,52660 +97649,52660 +97649,53867 +97585,53867 +97585,55104 +97774,55104 +97774,56255 +97196,56255 +97196,57546 +97636,57546 +97636,58780 +97591,58780 +97591,59958 +97238,59958 +97238,61063 +96596,61063 +96596,62184 +96091,62184 +96091,63423 +96024,63423 +96024,64739 +96152,64739 +96152,65592 +94869,65592 +94869,66846 +94784,66846 +94784,67925 +94219,67925 +94219,69237 +94206,69237 +94206,70195 +93369,70195 +93369,71228 +92725,71228 +92725,72421 +92396,72421 +92396,73353 +91573,73353 +91573,74531 +91190,74531 +91190,75402 +90295,75402 +90295,76446 +89686,76446 +89686,77385 +88921,77385 +88921,78413 +88284,78413 +88284,79671 +87931,79671 +87931,80568 +87102,80568 +87102,81220 +85994,81220 +85994,82478 +85581,82478 +85581,83480 +84863,83480 +84863,83949 +83605,83949 +83605,84603 +82559,84603 +82559,85593 +81829,85593 +81829,86686 +81171,86686 +81171,87253 +80061,87253 +80061,87969 +79082,87969 +79082,88669 +78093,88669 +78093,89502 +77196,89502 +77196,90250 +76233,90250 +76233,91130 +75347,91130 +75347,91250 +74000,91250 +74000,92327 +73212,92327 +73212,92894 +72128,92894 +72128,93270 +70952,93270 +70952,93370 +69660,93370 +69660,94478 +68819,94478 +68819,94708 +67595,94708 +67595,95183 +66472,95183 +66472,95207 +65195,95207 +65195,96147 +64221,96147 +64221,96615 +63081,96615 +63081,96461 +61777,96461 +61777,97201 +60700,97201 +60700,97015 +59412,97015 +59412,97740 +58305,97740 +58305,97562 +57038,97562 +57038,97176 +55764,97176 +55764,97302 +54566,97302 +54566,97656 +53385,97656 +53385,98146 +52195,98146 +52195,97889 +50969,97889 +50969,97871 +49756,97871 +49756,97859 +48543,97859 +48543,97449 +47351,97449 +47351,97738 +46119,97738 +46119,97642 +44909,97642 +44909,97226 +43740,97226 +43740,97219 +42519,97219 +42519,96788 +41367,96788 +41367,97309 +40026,97309 +40026,96882 +38868,96882 +38868,96221 +37780,96221 +37780,95804 +36640,95804 +36640,96136 +35265,96136 +35265,95792 +34086,95792 +34086,94892 +33112,94892 +33112,94733 +31866,94733 +31866,94172 +30777,94172 +30777,93317 +29828,93317 +29828,92857 +28705,92857 +28705,92156 +27705,92156 +27705,91484 +26696,91484 +26696,91543 +25258,91543 +25258,90924 +24200,90924 +24200,90213 +23201,90213 +23201,89043 +22528,89043 +22528,88927 +21108,88927 +21108,88089 +20204,88089 +20204,87315 +19255,87315 +19255,86250 +18557,86250 +18557,85773 +17347,85773 +17347,84679 +16696,84679 +16696,83809 +15843,83809 +15843,82679 +15268,82679 +15268,82055 +14153,82055 +14153,81303 +13157,81303 +13157,80213 +12558,80213 +12558,79102 +12004,79102 +12004,78475 +10804,78475 +10804,76971 +10824,76971 +10824,76102 +9952,76102 +9952,75038 +9369,75038 +9369,74238 +8339,74238 +8339,72905 +8231,72905 +8231,71987 +7378,71987 +7378,70721 +7205,70721 +7205,69997 +5885,69997 +5885,68793 +5582,68793 +5582,67760 +4871,67760 +4871,66522 +4679,66522 +4679,65214 +4737,65214 +4737,64207 +3895,64207 +3895,62932 +3915,62932 +3915,61848 +3259,61848 +3259,60571 +3366,60571 +3366,59436 +2864,59436 +2864,58155 +3122,58155 +3122,57084 +2124,57084 +2124,55838 +2213,55838 +2213,54652 +1807,54652 +1807,53424 +1794,53424 +1794,52197 +1810,52197 +1810,50973 +1890,50973 +1890,50228 +94822,50228 +94822,48525 +1557,48525 +1557,47341 +2383,47341 +2383,46107 +2110,46107 +2110,44867 +1961,44867 +1961,43734 +2727,43734 +2727,42467 +2452,42467 +2452,41283 +2754,41283 +2754,40077 +2933,40077 +2933,38872 +3134,38872 +3134,37713 +3522,37713 +3522,36439 +3506,36439 +3506,35262 +3852,35262 +3852,34252 +4684,34252 +4684,33262 +5505,33262 +5505,32101 +5846,32101 +5846,31022 +6392,31022 +6392,29688 +6381,29688 +6381,28480 +6689,28480 +6689,27621 +7685,27621 +7685,26247 +7715,26247 +7715,25643 +9102,25643 +9102,24398 +9389,24398 +9389,23514 +10255,23514 +10255,22573 +11021,22573 +11021,21166 +11150,21166 +11150,20538 +12337,20538 +12337,19792 +13336,19792 +13336,18451 +13627,18451 +13627,17941 +14878,17941 +14878,16560 +15179,16560 +15179,15977 +16322,15977 +16322,14917 +16989,14917 +16989,14500 +18254,14500 +18254,13050 +18605,13050 +18605,12768 +19956,12768 +19956,11585 +20576,11585 +20576,11164 +21786,11164 +21786,10359 +22708,10359 +22708,9858 +23836,9858 +23836,8777 +24596,8777 +24596,8258 +25713,8258 +25713,7978 +26955,7978 +26955,7540 +28095,7540 +28095,6507 +28940,6507 +28940,6682 +30363,6682 +30363,6251 +31489,6251 +31489,5782 +32598,5782 +32598,4548 +33429,4548 +33429,4750 +34790,4750 +34790,4015 +35829,4015 +35829,4049 +37104,4049 +37104,3690 +38261,3690 +38261,2708 +39279,2708 +39279,3314 +40653,3314 +40653,2568 +41748,2568 +41748,2300 +42941,2300 +42941,2002 +44135,2002 +44135,2479 +45412,2479 +45412,1845 +46579,1845 +46579,2346 +47826,2346 +47826,2049 +49029,2049 +49029,2462 +50242,2462 +50242,2326 +51451,2326 +51451,1711 +52695,1711 +52695,1956 +53904,1956 +53904,1808 +55148,1808 +55148,2309 +56320,2309 +56320,3006 +57444,3006 +57444,3165 +58640,3165 +58640,3456 +59812,3456 +59812,3478 +61045,3478 +61045,3412 +62316,3412 +62316,4049 +63401,4049 +63401,4368 +64572,4368 +64572,4266 +65892,4266 +65892,5403 +66775,5403 +66775,5880 +67884,5880 +67884,6132 +69090,6132 +69090,6792 +70119,6792 +70119,6784 +71472,6784 +71472,7784 +72326,7784 +72326,8026 +73577,8026 +73577,8876 +74490,8876 +74490,8978 +75860,8978 +75860,9930 +76701,9930 +76701,10352 +77896,10352 +77896,11232 +78772,11232 +78772,11817 +79867,11817 +79867,12626 +80792,12626 +80792,14062 +81171,14062 +81171,14424 +82471,14424 +82471,15055 +83557,15055 +83557,16158 +84188,16158 +84188,16772 +85314,16772 +85314,18188 +85573,18188 +85573,18598 +86957,18598 +86957,19899 +87301,19899 +87301,20942 +87937,20942 +87937,21902 +88675,21902 +88675,22692 +89662,22692 +89662,23972 +89932,23972 +89932,24741 +90987,24741 +90987,25832 +91538,25832 +91538,27127 +91708,27127 +91708,28094 +92461,28094 +92461,29086 +93191,29086 +93191,30203 +93671,30203 +93671,31293 +94211,31293 +94211,32525 +94402,32525 +94402,33715 +94665,33715 +94665,34739 +95400,34739 +95400,35775 +96158,35775 +96158,36914 +96627,36914 +96627,38153 +96733,38153 +96733,39465 +96473,39465 +96473,40509 +97404,40509 +97404,41858 +96797,41858 +96797,42955 +97601,42955 +97601,44214 +97352,44214 +97352,45389 +97756,45389 +97756,46601 +97847,46601 +97847,47809 +98021,47809 +98021,49037 +97534,49037 +97534,50245 From 1d6cdccaf8c18a2e70fc852fa1a530b61a9fab95 Mon Sep 17 00:00:00 2001 From: ktkk Date: Tue, 9 Dec 2025 09:24:55 +0000 Subject: [PATCH 05/17] Vectors! --- src/days/day09.zig | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/days/day09.zig b/src/days/day09.zig index e85cb36..0a0044b 100644 --- a/src/days/day09.zig +++ b/src/days/day09.zig @@ -30,7 +30,7 @@ pub fn run(allocator: std.mem.Allocator) !void { const s = coordinates.next() orelse continue; break :blk try std.fmt.parseUnsigned(u64, s, 10); }; - try tiles.append(allocator, .{ .x = x, .y = y }); + try tiles.append(allocator, .{ .pos = .{ x, y } }); } var largest_area: usize = 0; @@ -58,13 +58,12 @@ pub fn run(allocator: std.mem.Allocator) !void { } const Tile = struct { - x: u64, - y: u64, + pos: @Vector(2, u64), const Self = @This(); pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { - try w.print("{d},{d}", .{self.x, self.y}); + try w.print("{d},{d}", .{self.pos[0], self.pos[1]}); } pub fn rectangle(self: Self, other_corner: Self) Rectangle { @@ -83,9 +82,12 @@ const Rectangle = struct { } pub fn area(self: Self) u64 { - const width = @max(self.a.x, self.b.x) - @min(self.a.x, self.b.x) + 1; - const height = @max(self.a.y, self.b.y) - @min(self.a.y, self.b.y) + 1; - return width * height; + const cond = self.a.pos > self.b.pos; + const high = @select(u64, cond, self.a.pos, self.b.pos); + const low = @select(u64, !cond, self.a.pos, self.b.pos); + const diff = high - low; + const one: @Vector(2, u64) = @splat(1); + return @reduce(.Mul, diff + one); } }; From 605b5ee85ad5d5f4e591b5d4910a809a6a0fc054 Mon Sep 17 00:00:00 2001 From: ktkk Date: Tue, 9 Dec 2025 16:32:37 +0000 Subject: [PATCH 06/17] WIP: implement part 2 --- src/days/day09.zig | 94 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 81 insertions(+), 13 deletions(-) diff --git a/src/days/day09.zig b/src/days/day09.zig index 0a0044b..b51820c 100644 --- a/src/days/day09.zig +++ b/src/days/day09.zig @@ -3,24 +3,26 @@ const std = @import("std"); pub const title = "Day 09: Movie Theater"; pub fn run(allocator: std.mem.Allocator) !void { - const input = @embedFile("./input/day09.txt"); - //const input = - // \\7,1 - // \\11,1 - // \\11,7 - // \\9,7 - // \\9,5 - // \\2,5 - // \\2,3 - // \\7,3 - // ; + //const input = @embedFile("./input/day09.txt"); + const input = + \\7,1 + \\11,1 + \\11,7 + \\9,7 + \\9,5 + \\2,5 + \\2,3 + \\7,3 + ; var lines = std.mem.tokenizeScalar(u8, input, '\n'); var tiles: std.ArrayList(Tile) = .empty; defer tiles.deinit(allocator); + var index: usize = 0; while (lines.next()) |line| { + defer index += 1; var coordinates = std.mem.tokenizeScalar(u8, line, ','); const x = blk: { const s = coordinates.next() orelse continue; @@ -30,20 +32,53 @@ pub fn run(allocator: std.mem.Allocator) !void { const s = coordinates.next() orelse continue; break :blk try std.fmt.parseUnsigned(u64, s, 10); }; - try tiles.append(allocator, .{ .pos = .{ x, y } }); + try tiles.append(allocator, .{ .index = index, .pos = .{ x, y } }); + } + + const width = 14; + const height = 9; + for (0..height) |y| { + var buffer: [width]u8 = [_]u8{'.'} ** width; + for (0..width) |x| { + for (tiles.items) |tile| { + if (@reduce(.And, tile.pos == @Vector(2, u64){ x, y })) { + buffer[x] = 'X'; + } + } + } + std.debug.print("{s}\n", .{buffer}); } var largest_area: usize = 0; var largest_rectangle: Rectangle = undefined; for (tiles.items, 0..) |first_tile, i| { + if (i == 0) continue; for (tiles.items[i + 1..]) |second_tile| { const rectangle = first_tile.rectangle(second_tile); + const w = rectangle.width(); + const h = rectangle.height(); + std.debug.print("rectangle {d}-{d}\n", .{rectangle.a.index, rectangle.b.index}); + std.debug.print("width = {d}, height = {d}\n", .{w, h}); + + if (w != 1 and h != 1) { + var verts_outside: bool = false; + for (tiles.items[first_tile.index + 1..second_tile.index]) |between| { + const cond = rectangle.c > between.pos; + if (@reduce(.Or, cond)) { + std.debug.print("vert c ({any}) of rect {d}-{d} is outside the shape\n", .{rectangle.c, rectangle.a.index, rectangle.b.index}); + verts_outside = true; + break; + } + } + } + const area = rectangle.area(); if (area > largest_area) { largest_area = area; largest_rectangle = rectangle; } } + break; } std.debug.print("rectangle = {f}\n", .{largest_rectangle}); @@ -58,6 +93,7 @@ pub fn run(allocator: std.mem.Allocator) !void { } const Tile = struct { + index: usize, pos: @Vector(2, u64), const Self = @This(); @@ -67,20 +103,52 @@ const Tile = struct { } pub fn rectangle(self: Self, other_corner: Self) Rectangle { - return .{ .a = self, .b = other_corner }; + const a = self; + const b = other_corner; + return .{ + .a = a, + .b = b, + .c = .{ b.pos[0], a.pos[1] }, + .d = .{ a.pos[0], b.pos[1] }, + }; } }; +/// 0,0 1,0 +/// a ---- c +/// | | +/// | | +/// d ---- b +/// 0,1 1,1 const Rectangle = struct { a: Tile, b: Tile, + c: @Vector(2, u64), + d: @Vector(2, u64), + const Self = @This(); pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { try w.print("{f} to {f}", .{self.a, self.b}); } + pub fn width(self: Self) u64 { + const cond = self.a.pos > self.b.pos; + const high = @select(u64, cond, self.a.pos, self.b.pos); + const low = @select(u64, !cond, self.a.pos, self.b.pos); + const diff = high - low; + return diff[0] + 1; + } + + pub fn height(self: Self) u64 { + const cond = self.a.pos > self.b.pos; + const high = @select(u64, cond, self.a.pos, self.b.pos); + const low = @select(u64, !cond, self.a.pos, self.b.pos); + const diff = high - low; + return diff[1] + 1; + } + pub fn area(self: Self) u64 { const cond = self.a.pos > self.b.pos; const high = @select(u64, cond, self.a.pos, self.b.pos); From 5a8bf213860ea17d6af4ef18a60dfcb8df259df9 Mon Sep 17 00:00:00 2001 From: ktkk Date: Tue, 9 Dec 2025 21:09:38 +0000 Subject: [PATCH 07/17] Finish day09, part 2 This doesn't work on the example but it does work on the actual dataset. TODO: Fix that --- src/days/day09.zig | 167 +++++++++++++++++++++++++++++++++------------ 1 file changed, 124 insertions(+), 43 deletions(-) diff --git a/src/days/day09.zig b/src/days/day09.zig index b51820c..c167255 100644 --- a/src/days/day09.zig +++ b/src/days/day09.zig @@ -3,23 +3,24 @@ const std = @import("std"); pub const title = "Day 09: Movie Theater"; pub fn run(allocator: std.mem.Allocator) !void { - //const input = @embedFile("./input/day09.txt"); - const input = - \\7,1 - \\11,1 - \\11,7 - \\9,7 - \\9,5 - \\2,5 - \\2,3 - \\7,3 - ; + const input = @embedFile("./input/day09.txt"); + //const input = + // \\7,1 + // \\11,1 + // \\11,7 + // \\9,7 + // \\9,5 + // \\2,5 + // \\2,3 + // \\7,3 + // ; var lines = std.mem.tokenizeScalar(u8, input, '\n'); var tiles: std.ArrayList(Tile) = .empty; defer tiles.deinit(allocator); + std.debug.print("parsing tiles...\n", .{}); var index: usize = 0; while (lines.next()) |line| { defer index += 1; @@ -35,39 +36,56 @@ pub fn run(allocator: std.mem.Allocator) !void { try tiles.append(allocator, .{ .index = index, .pos = .{ x, y } }); } - const width = 14; - const height = 9; - for (0..height) |y| { - var buffer: [width]u8 = [_]u8{'.'} ** width; - for (0..width) |x| { - for (tiles.items) |tile| { - if (@reduce(.And, tile.pos == @Vector(2, u64){ x, y })) { - buffer[x] = 'X'; - } - } - } - std.debug.print("{s}\n", .{buffer}); + std.debug.print("calculating edges...\n", .{}); + var edges: std.ArrayList(Edge) = .empty; + defer edges.deinit(allocator); + for (tiles.items, 0..) |tile, i| { + const a = tile; + const b = if (i == tiles.items.len - 1) tiles.items[0] else tiles.items[i + 1]; + try edges.append(allocator, Edge.fromTiles(a, b)); } + std.debug.print("finding largest rectangle...\n", .{}); var largest_area: usize = 0; var largest_rectangle: Rectangle = undefined; for (tiles.items, 0..) |first_tile, i| { - if (i == 0) continue; - for (tiles.items[i + 1..]) |second_tile| { + inner: for (tiles.items[i + 1..]) |second_tile| { const rectangle = first_tile.rectangle(second_tile); - const w = rectangle.width(); - const h = rectangle.height(); - std.debug.print("rectangle {d}-{d}\n", .{rectangle.a.index, rectangle.b.index}); - std.debug.print("width = {d}, height = {d}\n", .{w, h}); - if (w != 1 and h != 1) { - var verts_outside: bool = false; - for (tiles.items[first_tile.index + 1..second_tile.index]) |between| { - const cond = rectangle.c > between.pos; - if (@reduce(.Or, cond)) { - std.debug.print("vert c ({any}) of rect {d}-{d} is outside the shape\n", .{rectangle.c, rectangle.a.index, rectangle.b.index}); - verts_outside = true; - break; + std.debug.print("checking rectangle {f}...\n", .{rectangle}); + + const has_inside = rectangle.width() >= 3 and rectangle.height() >= 3; + if (has_inside) { + const one: @Vector(2, u64) = @splat(1); + const top_left = rectangle.topLeft() + one; + const bottom_right = rectangle.bottomRight() - one; + edge_loop: for (edges.items) |edge| { + if (edge.direction == .horizontal) { + if (edge.a.pos[1] < top_left[1] or edge.a.pos[1] > bottom_right[1]) { + continue :edge_loop; + } + + const start, const end = if (edge.a.pos[0] < edge.b.pos[0] + 1) .{ edge.a.pos[0], edge.b.pos[0] } else .{ edge.b.pos[0], edge.a.pos[0] + 1 }; + for (start..end) |ex| { + const edge_tile: @Vector(2, u64) = .{ ex, edge.a.pos[1] }; + if (top_left[0] <= edge_tile[0] and edge_tile[0] <= bottom_right[0]) { + std.debug.print("rectangle {f} hits edge {f}\n", .{rectangle, edge}); + continue :inner; + } + } + } else { + if (edge.a.pos[0] < top_left[0] or edge.a.pos[0] > bottom_right[0]) { + continue :edge_loop; + } + + const start, const end = if (edge.a.pos[1] < edge.b.pos[1] + 1) .{ edge.a.pos[1], edge.b.pos[1] } else .{ edge.b.pos[1], edge.a.pos[1] + 1 }; + for (start..end) |ey| { + const edge_tile: @Vector(2, u64) = .{ edge.a.pos[0], ey }; + if (top_left[1] <= edge_tile[1] and edge_tile[1] <= bottom_right[1]) { + std.debug.print("rectangle {f} hits edge {f}\n", .{rectangle, edge}); + continue :inner; + } + } } } } @@ -78,10 +96,10 @@ pub fn run(allocator: std.mem.Allocator) !void { largest_rectangle = rectangle; } } - break; } std.debug.print("rectangle = {f}\n", .{largest_rectangle}); + std.debug.print("top_left = {any}, bottom_right = {any}\n", .{largest_rectangle.topLeft(), largest_rectangle.bottomRight()}); var buffer: [64]u8 = undefined; var stdout_writer = std.fs.File.stdout().writer(&buffer); @@ -103,15 +121,41 @@ const Tile = struct { } pub fn rectangle(self: Self, other_corner: Self) Rectangle { - const a = self; - const b = other_corner; + return Rectangle.fromTiles(self, other_corner); + } +}; + +const Edge = struct { + a: Tile, + b: Tile, + + direction: Direction, + + const Self = @This(); + + const Direction = enum { + horizontal, + vertical, + }; + + pub fn fromTiles(a: Tile, b: Tile) Self { + const direction: Direction = if (a.pos[0] == b.pos[0]) + .vertical + else if (a.pos[1] == b.pos[1]) + .horizontal + else + unreachable; + return .{ .a = a, .b = b, - .c = .{ b.pos[0], a.pos[1] }, - .d = .{ a.pos[0], b.pos[1] }, + .direction = direction, }; } + + pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { + try w.print("{f} - {f}", .{self.a, self.b}); + } }; /// 0,0 1,0 @@ -129,8 +173,45 @@ const Rectangle = struct { const Self = @This(); + pub fn fromTiles(a: Tile, b: Tile) Self { + const cx = if (a.pos[0] <= b.pos[0]) b.pos[0] else a.pos[0]; + const cy = if (a.pos[1] >= b.pos[1]) a.pos[1] else b.pos[1]; + const dx = if (a.pos[0] <= b.pos[0]) a.pos[0] else b.pos[0]; + const dy = if (a.pos[1] >= b.pos[1]) b.pos[1] else a.pos[1]; + return .{ + .a = a, + .b = b, + .c = .{ cx, cy }, + .d = .{ dx, dy }, + }; + } + pub fn format(self: Self, w: *std.io.Writer) std.io.Writer.Error!void { - try w.print("{f} to {f}", .{self.a, self.b}); + try w.print("{d} to {d} ({f} - {d},{d} - {f} - {d},{d})", .{self.a.index, self.b.index, self.a, self.c[0], self.c[1], self.b, self.d[0], self.d[1]}); + } + + pub fn topLeft(self: Self) @Vector(2, u64) { + const verts = [_]@Vector(2, u64){ self.c, self.b.pos, self.d }; + var top_left: @Vector(2, u64) = self.a.pos; + for (verts) |vert| { + const cond = vert <= top_left; + if (@reduce(.And, cond)) { + top_left = vert; + } + } + return top_left; + } + + pub fn bottomRight(self: Self) @Vector(2, u64) { + const verts = [_]@Vector(2, u64){ self.d, self.a.pos, self.c }; + var bottom_right: @Vector(2, u64) = self.b.pos; + for (verts) |vert| { + const cond = vert >= bottom_right; + if (@reduce(.And, cond)) { + bottom_right = vert; + } + } + return bottom_right; } pub fn width(self: Self) u64 { From 37b740f07a5545292a81887d6450f113c4219ecc Mon Sep 17 00:00:00 2001 From: ktkk Date: Thu, 11 Dec 2025 12:15:11 +0000 Subject: [PATCH 08/17] Finish day11, part 1 --- src/days/day11.zig | 76 ++++- src/days/input/day11.txt | 609 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 683 insertions(+), 2 deletions(-) create mode 100755 src/days/input/day11.txt diff --git a/src/days/day11.zig b/src/days/day11.zig index d16d9d5..cfbf883 100644 --- a/src/days/day11.zig +++ b/src/days/day11.zig @@ -1,7 +1,79 @@ const std = @import("std"); -pub const title = "Day 11"; +pub const title = "Day 11: Reactor"; -pub fn run(_: std.mem.Allocator) !void { +pub fn run(allocator: std.mem.Allocator) !void { + const input = @embedFile("./input/day11.txt"); + //const input = + // \\aaa: you hhh + // \\you: bbb ccc + // \\bbb: ddd eee + // \\ccc: ddd eee fff + // \\ddd: ggg + // \\eee: out + // \\fff: out + // \\ggg: out + // \\hhh: ccc fff iii + // \\iii: out + // ; + + var lines = std.mem.tokenizeScalar(u8, input, '\n'); + + var devices: std.StringHashMap([][]const u8) = .init(allocator); + defer { + var outputs_iter = devices.valueIterator(); + while (outputs_iter.next()) |value| { + allocator.free(value.*); + } + devices.deinit(); + } + + while (lines.next()) |line| { + const device = line[0..3]; + std.debug.print("device = {s}\n", .{device}); + + var outputs: std.ArrayList([]const u8) = .empty; + defer outputs.deinit(allocator); + + var outputs_iter = std.mem.tokenizeScalar(u8, line[5..], ' '); + while (outputs_iter.next()) |output| { + try outputs.append(allocator, output); + } + + const outputs_slice = try outputs.toOwnedSlice(allocator); + errdefer allocator.free(outputs_slice); + + try devices.put(device, outputs_slice); + } + + var paths_to_out: usize = 0; + visitOutputs("you", devices, &paths_to_out); + + var buffer: [8]u8 = undefined; + var stdout_writer = std.fs.File.stdout().writer(&buffer); + const stdout = &stdout_writer.interface; + + try stdout.print("{d}\n", .{paths_to_out}); + + try stdout.flush(); +} + +fn visitOutputs( + start: []const u8, + devices: std.StringHashMap([][]const u8), + paths_to_out: *usize, +) void { + const device = devices.get(start); + if (device) |outputs| { + for (outputs) |output| { + if (std.mem.eql(u8, output, "out")) { + paths_to_out.* += 1; + } else { + visitOutputs(output, devices, paths_to_out); + } + } + } else { + std.debug.print("device {s} not found\n", .{start}); + } } diff --git a/src/days/input/day11.txt b/src/days/input/day11.txt new file mode 100755 index 0000000..1c6713e --- /dev/null +++ b/src/days/input/day11.txt @@ -0,0 +1,609 @@ +smx: otc +mmh: gvp +gbo: hyf alz +laa: vky qjq +vrn: tbs tsr jix +xyl: xel eur wdj +sxm: out +wsd: kua hpv jep +qsj: ulu xel eur wdj +xwa: mtd xxf hnw +kai: ehr kaj +uuj: you +owb: ixr bps pim eez ejn syt qrx hxw vsy ghl gfu cgh mpk kfj +vky: owb wlw qic +ysd: mkp jbf btz xgg gbk tvg iju amm dws ykz azc blh xld rpr uek rcl zzy jhu +rbc: ski xyl sdx wpw +zmc: pal lwb rns hex +cuu: vyo +bqf: kmy exx ish +jbv: ysa +aog: ayv kwq +fcq: qic xss owb +hyg: out +xoz: llx kra cqn bzn swe tdo vnz zos duw +gnq: eya +qmk: fcq lyd +ggp: brz eya +oit: yyy quh brz +hjl: dtj lnc jps fyr +sqg: xbz upq +nil: diq +xqa: jei ipw tkt +ond: fft jko dqj pxe +and: ahn izm esa +cqf: xss +rqa: ryb rwu ono fyb +jps: byj fmv shn +ccg: ond afk tbu +dta: ctq jbw whr smq +ztx: hlm ctr vgo maf fkj +sdx: xel eur +xwb: dds +clh: ktb +rtn: quh eya +dac: nxc vug eou +nvh: kmf yga wtv +xgw: kep unr lju mtm +mdx: qmk fwk fbd +tbu: fft dqj pxe +vil: lyz aek +ona: zjk ovx dmv laa +bld: zbs +rms: vjs znm +oku: brz yyy +bzn: dmc fwa ykh vrn axj +uzl: ayv fuz qhs kwq +bhz: ggv +kfj: xqa ucr akl +koi: szi +mvo: dqp kjr rbc +rof: vgo hlm +ixt: jws nxc vug +ycf: out +dmc: tsr +nam: mvo +rkj: quh yyy eya brz +qxk: uty +lwb: phc esx +fqf: isr dax +eou: lqz ysd +lbb: out +hyf: fgh wem yen taw +dfv: nzl +pnh: lai +jon: eya +guf: shn +lmw: hlu mhq +jff: ngn gye +xxj: guf dtj lnc +fbd: fcq lyd +idw: cmg phc +zbs: hjl +lqz: blh ttg ykz jhu zzy uek rcl bld xgg gbk mkp amm iju tvg +shn: goi +hdc: wap pvr +odf: yey ggp jtc +rkk: zyi ubs +fyr: fmv vtv +pxe: ztx mmi +ntf: dds cst aff +lyz: gwp +pyt: zpv ias oiz +cqx: rod jnp +dtj: shn vtv +gfu: kai ctq +ycw: ryl ixt uut dac +yvb: jbv rms fez +lvx: tvz vyo +pvr: yat +oiz: zjk ovx dmv +biy: tdg +xbz: cqf +obk: jje +jcc: ssq daa +elu: ihl kep lju unr +jgf: qfx bhz +wbp: xxj cap hjl +nne: out +llx: axj ykh +kso: kuk ams +eod: nzl aap +ryl: nxc +epd: eou jws ats nxc vug +wqg: uzn yyf +qhh: lqz +fhu: hex idw pal +ipt: ema +vpo: cap xxj +thl: azd otc +ttg: vpo +uty: owb qic +brz: mdl eiw gam aog nam wqg jcc kgs nac bsk zpk kul snr uzl +faw: out +lzw: wlw xss owb qic +wap: iel yat qhh paa +ffr: vnn fiv +nug: sqg eyp sws eai dsh icy zrp mas dmf ccg hoq qze qde cqt zvl jrq gep +ygk: jon oit +eya: ppx nac mdl dej +lnc: byj fmv shn +nhq: kjv +biq: lav xhe vcg +hfn: pvr ydj +leg: oii zad jje +fft: rof taz +maf: qic +aap: rkj hrs svl +axv: esa +zou: ulu eur xel +jtc: yyy +pxc: gvr dyo omt +byj: nqz goi faw +ykh: jix tbs tsr +fai: cst nug aff +oty: nhq +cek: vvv ubs zyi +ufu: zen +xtk: kpg tap qzv +kil: dds aff +ojk: lqz +aly: qak lqz +xxf: aff cst dds +yua: oit ktb rwv +vlf: ujz +lbw: zyi uuj +zpk: nhp urn ctg +kuk: you ysd qak +tmy: esa +sqi: quh lvi +jrq: obk leg +yat: lqz +atl: zpv ias oiz ona obm +xhe: asz jbv +gdx: oii jje +ssq: fqf tap kpg qzv +quh: snr kul zpk bsk nac ufu yor dej ppx aog nam wqg eiw mdl +bvn: luk +zny: jon ktb rwv +jzw: aap plm +jqp: dac +mpk: euv llh +fpr: gwp zmc ulq fhu +ahn: qtl rtn +zyi: lqz ysd +ypn: mtd xxf +fgh: rkk +vgo: xss owb wlw +axj: jix tsr +kgv: kpg +gfa: ona obm zpv ias +eur: eij vil oxs xip hsd hdc gbo laz rnq lnj nuk xck twd jqp ycw btu abg koi cey hfn +bsk: oqd hmt kew +wrx: tas +jix: aff nug cst dds qvv +blc: yan +rwv: yyy quh eya brz +exx: blc dks +ujz: mwp +yyf: xya xmb fee +icq: mtm +hxw: viq eod +xii: fyb +lyb: drx mlf pkl +puw: ona ias +ilj: qfx xph +wlw: gfu ghl vlf cgh mpk yfx pbj qrx hxw jsq eez syt dta ejn bps hnj pim +icy: xbz +wdr: gbm kil +svl: lvi +dax: wdj eur +fwa: jix tsr +fyb: you ysd qak +whr: ehr kaj ogx nvh +agb: mag yan +duw: luk yzp nil +plg: yen taw fks wem fgh +zrp: pyt puw qyk gfa atl +phc: you qak lqz +aff: qze hoq qde mdx zvl jrq sqg dsh eai zrp icy mas dmf +ulu: lnj xck twd jqp btu ycw abg koi gqf hfn eij vil oxs xip nhi hsd hdc kku laz rnq +ezt: nug cst qvv dds +ccu: yyy brz eya +nuk: zpf +ubs: ysd +qyk: ona oiz +kua: wlw xss qic +ssa: kua +uds: ier vnn fiv +cbw: gvr +pln: wdj ulu +zos: htz ilj +viq: aap nzl +azd: jff +esa: rtn oku +rzd: eya brz +syt: euv cbo +drx: tdg +qjq: xss owb +jru: aat eoy dqu +vms: bzf gkm ffr uds +zen: vms zuv vci +qfx: wdr +amm: wbp vpo evr jmb zbs +hnj: sxp viq jzw +vtv: goi +kep: xnp yoh evy +evr: cap +gvp: yyy brz lvi eya +kxs: rod jru uvb +daa: jlo +fks: lbw cek +omt: dds +gtx: out +jws: lqz qak +eoy: out +qvv: fes dmf icy zrp eai dsh iyb sqg eyp sws gep jrq mdx zvl qfd qde qze hoq ccg +smq: kaj +kmy: agb +qde: atl +fez: znm mvj vjs +cey: wrx ryw lbx +ema: brz eya lvi quh yyy +zfg: cst nug aff qvv +pim: yip pxl ujz +zge: lzw +ykz: yrg bss smx +yyy: snr zpk uzl ufu bsk dej yte kgs gam eiw wqg +yor: kew +cmg: lqz qak ysd +xya: zou pln uaz +zpv: laa +yen: cek rkk fce iwk +boc: eay hlu +ygu: xya ofj +xnp: oic zfg eft xwb +nlb: izm +fmv: nqz +mag: aem wtx qrc pyc ipu +tdo: jgf +znm: sxm lbb +mtm: xnp +khk: ipt qvi +vyo: eur wdj +kye: out +uvb: dqu aat yvz +xck: lyz fpr aek arq +acb: wtv gts +gep: qxk upq +ihl: xnp yoh +eyp: qyk +lai: qsj +ipu: out +isr: ulu +qrc: out +jhu: bqf +eij: uut dac ryl epd +tvg: yrg thl mvu bss +pbj: ucr +cst: ccg sws hoq qze dsh qde cqt +yzp: xwa diq cft ypn +uut: eou ats +fee: zou +dqj: mmi taz rof ztx +rnq: arq aek +yfk: yvb zzh +lvi: jcc dej mdl gam aog nam zpk kul uzl ufu bsk nac +tap: sxw +jsq: dfv sxp viq jzw +tdg: aff nug cst dds +cgh: tmy oze nlb and +qzv: dax +jtn: xhe +kjr: ski wpw sdx xyl +ski: wdj xel +oqd: zuv +ppx: zen hmt kew +vcg: jbv +jbw: nvh +ctg: dqp +dcv: owb wlw qic +kzs: rxd lai cuu lvx +dws: bss yrg thl mvu +ara: dds qvv cst nug aff +ctr: owb wlw +ctq: ehr kaj acb +zpf: fgh fks +pyc: out +ras: gvr omt +iby: xxb rqa vlx +gam: mah ygu uzn +ulq: idw lwb pal +gkm: ier +cqn: pdv elu +tvz: ulu +obm: laa +btu: alz +wtx: out +xel: oty oxs vil eij hsd nhi hdc gbo kku lnj ycw btu jqp xck gqf hfn cey koi abg +uxa: lwb hex rns +yga: gnq +ppv: lav xhe vcg +upq: hzh cqf lzw uty +mvu: otc exw +yrg: otc azd +kul: qsu xtk ssq daa kgv +pif: mbd bzn mzo xhj wee jdf +xhy: wus khk mwp +ehr: wtv gts yga +fes: zge +rwu: you qak ysd lqz +hnw: cst +goi: out +hsd: alz zpf amk +hzh: wlw xss qic +lbs: vlx rqa +dds: mdx zvl qde qfd qze jrq zrp icy iyb dsh eyp sqg fes dmf mas +tsh: hpv kua +svr: xoz lak pif ryf dyv +gua: hlu +jei: jtc ggp +wpw: xel eur wdj ulu +jbf: biq jtn hut ppv yfk +hoq: qmk fwk cxr fbd +blh: evr vpo zbs jmb +mas: gdx +afk: jko pxe +zzy: lmw boc +vsy: tmy oze axv and +htz: xph qfx bhz +yte: mah ygu uzn rcr +zuv: bzf gkm ffr uds +yvz: out +ejn: dok llh euv +jlo: dax isr +qvi: gvp ema rzd +mdl: mah +wdj: hfn gqf cey koi jqp twd lnj rnq gbo kku hdc hsd oty vil eij abg ycw btu xck nuk nhi oxs +ias: dmv zjk ovx +laz: nhq +ish: blc +pkl: ezt ara +xhj: elu +tlp: ais +mux: zrm uvb +vci: bzf gkm uds +nie: wtx aem qrc +ike: wdj xel ulu +abg: pvr wap +ono: lqz +yip: khk +oze: ahn izm +lak: bvn mbd llx xhj lyb pxo +dmf: obk leg +wus: ipt qvi +oic: nug cst qvv dds +rpr: ifc fjg mfu +vvv: qak +qtl: lvi brz quh yyy +rqt: pdv icq +yoh: eft ntf oic +aby: nug dds +yfx: axv tmy +xmb: uaz pln +hrs: brz quh yyy +eez: llh cbo +lyd: qic owb xss wlw +dyo: dds qvv aff cst nug +evy: xwb eft ntf +plv: esz ktb jon +luk: xwa ypn +nqz: out +ier: wdj eur ulu +yey: quh eya lvi brz +otc: svv tlp jff +qze: leg gdx obk +aek: gwp ulq +mah: xmb fee xya +pxl: khk xux wus +wem: iwk cek lbw rkk +nhi: uut ryl epd +cui: out +qak: ykz xmj jbf rpr xgg blh +qwm: eya lvi brz quh +dsh: zge qxk upq xbz +hmt: zuv +bss: azd otc +rxd: vyo qsj +eay: uhs mux kxs +vnn: ulu wdj eur xel +iju: ckk lmw gua +fiv: wdj eur xel ulu +izm: rtn oku +xld: fjg mfu ifc +xph: ggv nqb +ija: rxd cuu +tsr: nug cst aff dds qvv +uaz: ulu wdj eur +ats: lqz you qak ysd +cft: xxf aby +taw: iwk cek lbw rkk +rns: ojk phc +qic: vlf eez cgh yfx dta syt bps hnj jsq +gqf: zpf amk plg hyf +ryb: qak +tbs: nug aff qvv dds +gbk: yfk +eiw: mvo ctg urn abp +kpg: sxw isr +pal: phc ojk esx +ais: nne hyg kye ycf +fjg: kmy +uzn: fee xmb +hpv: owb xss wlw qic +hlu: mux cqx +azc: ckk lmw boc +dqp: xyl ike +aat: out +fuz: srk pnh ija +ypw: jgf +pdv: kep +dmv: qjq vky +fya: llv iby lbs +plm: rkj +xux: ipt qvi mmh +gye: kye gme +zzh: fez asz rms +snr: ayv fuz qhs +ydj: qhh akg paa +rcr: ofj fee xmb xya +kaj: wtv kmf yga +lju: yoh evy +ebo: sqi jtc yey +vlx: rwu ryb ono +tas: xxb xii +wee: pdv xgw +fkj: owb wlw +xro: ilj htz jgf +hum: lqz ysd +kku: bsy aek lyz +euv: clh plv yua ygk +akl: ebo jei tkt odf +lnj: fya lbx +lbx: iby lbs +mhq: cqx uhs +hut: vcg zzh +szi: mnj ams +ysa: sxm rni lbb +vug: you +llh: ygk yua zny plv clh +nzl: hrs +uek: mvu +mmi: maf vgo hlm +eft: dds cst +dok: zny yua clh plv +kmf: npf lef nsp +mnj: you qak ysd lqz +paa: qak you +ghl: xhy +ggv: kil gbm fai lvh +jje: ssa +jko: mmi +srk: rxd +yan: ipu +nxc: lqz you qak +gts: qwm npf lef gnq +qrx: kai smq whr +ovx: oiw +unr: evy xnp +kew: vms vci +sxp: aap +oii: tsh wsd +cbo: ygk clh +xip: wrx lbx +sws: ond tbu +abp: rbc +tkt: ccu ggp +diq: xxf mtd hnw +gvr: nug cst +ipw: jtc ccu +arq: uxa gwp ulq +iwk: vvv uuj aly zyi +mfu: exx kmy +dks: nie mag +twd: fpr lyz arq bsy +fwk: lyd +jnp: eoy aat +nsp: brz eya yyy +xss: vsy bps ixr hxw syt pbj kfj gfu +nac: kgv xtk qsu +oiw: qic xss owb wlw +svv: ais gye +mtd: cst dds qvv +ixr: and nlb axv +jdf: pxc cbw +dyv: dea wnr xro ypw xlu +qfd: afk ond +wtv: qwm nsp +xxb: rwu ryb fyb ono +wnr: xgw elu +uhs: uvb zrm jnp rod jru +asz: mvj vjs +eai: gfa puw +ofj: uaz +vnz: pkl +kgs: mvo urn abp ctg +fce: ubs uuj vvv +pxo: vrn fwa dmc ykh +cxr: lyd fcq dcv +xgg: ifc +mzo: biy pkl mlf +gwp: pal idw rns hex +you: dws amm iju tvg bld xgg jbf btz mkp jhu uek blh xld ykz ttg azc +jep: wlw xss +nqb: lvh +zrm: yvz eoy aat cui +zmm: odf ipw jei +kjv: qak ysd +akg: you ysd lqz +lvh: qvv dds aff cst +ogx: gts yga +urn: kjr rbc +bsy: uxa fhu zmc gwp ulq +lav: asz fez +exw: svv +esz: lvi +sxw: eur xel +ams: lqz +qsu: fqf kpg tap +bps: akl zmm xqa +ayv: srk pnh ija kzs +gme: out +oxs: szi nhq kso +hex: esx hum ojk cmg phc +xlu: luk +aem: out +mlf: ara +kwq: srk pnh kzs +jmb: xxj cap +dqu: out +iel: ysd +ucr: ipw +cqt: fbd qmk fwk +nhp: dqp kjr +ifc: ish +llv: rqa xii xxb +dea: luk yzp nil +ngn: nne gme ycf hyg +ryf: xlu rqt swe bvn lyb duw cqn bzn jdf wnr wee ypw pxo vnz xhj zos +lef: brz quh +mbd: pxc +cap: dtj guf +rcl: wbp evr vpo jmb +zvl: fbd cxr fwk +btz: lmw gua +ktb: brz yyy +taz: ctr hlm vgo fkj +mkp: jtn hut yfk ppv +iyb: afk tbu +gbm: nug dds +swe: ras +ckk: hlu eay +rni: out +bzf: fiv +qhs: ija +rod: yvz +amk: yen taw +vjs: rni sxm +hlm: owb xss +zjk: oiw +mvj: gtx rni +ryw: iby llv +npf: quh brz lvi +zad: ssa tsh +esx: lqz ysd +mwp: mmh +alz: wem yen +kra: luk nil +xmj: smx +dej: kew From f85eda4e870dba5bd8fe6b5b1f2ff05c9167856d Mon Sep 17 00:00:00 2001 From: ktkk Date: Thu, 11 Dec 2025 15:48:33 +0000 Subject: [PATCH 09/17] WIP: implement part 2 --- src/days/day11.zig | 39 +++++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/src/days/day11.zig b/src/days/day11.zig index cfbf883..2525215 100644 --- a/src/days/day11.zig +++ b/src/days/day11.zig @@ -5,16 +5,19 @@ pub const title = "Day 11: Reactor"; pub fn run(allocator: std.mem.Allocator) !void { const input = @embedFile("./input/day11.txt"); //const input = - // \\aaa: you hhh - // \\you: bbb ccc - // \\bbb: ddd eee - // \\ccc: ddd eee fff - // \\ddd: ggg - // \\eee: out - // \\fff: out + // \\svr: aaa bbb + // \\aaa: fft + // \\fft: ccc + // \\bbb: tty + // \\tty: ccc + // \\ccc: ddd eee + // \\ddd: hub + // \\hub: fff + // \\eee: dac + // \\dac: fff + // \\fff: ggg hhh // \\ggg: out - // \\hhh: ccc fff iii - // \\iii: out + // \\hhh: out // ; var lines = std.mem.tokenizeScalar(u8, input, '\n'); @@ -47,7 +50,7 @@ pub fn run(allocator: std.mem.Allocator) !void { } var paths_to_out: usize = 0; - visitOutputs("you", devices, &paths_to_out); + visitOutputs("svr", devices, &paths_to_out, false, false); var buffer: [8]u8 = undefined; var stdout_writer = std.fs.File.stdout().writer(&buffer); @@ -62,14 +65,26 @@ fn visitOutputs( start: []const u8, devices: std.StringHashMap([][]const u8), paths_to_out: *usize, + visited_fft: bool, + visited_dac: bool, ) void { const device = devices.get(start); if (device) |outputs| { for (outputs) |output| { if (std.mem.eql(u8, output, "out")) { - paths_to_out.* += 1; + std.debug.print("found out! (fft = {any}, dac = {any})\n", .{visited_fft, visited_dac}); + if (visited_fft and visited_dac) { + std.debug.print("visited fft and dac\n", .{}); + paths_to_out.* += 1; + } + } else if (std.mem.eql(u8, output, "fft")) { + std.debug.print("found fft!\n", .{}); + visitOutputs(output, devices, paths_to_out, true, visited_dac); + } else if (std.mem.eql(u8, output, "dac")) { + std.debug.print("found dac!\n", .{}); + visitOutputs(output, devices, paths_to_out, visited_fft, true); } else { - visitOutputs(output, devices, paths_to_out); + visitOutputs(output, devices, paths_to_out, visited_fft, visited_dac); } } } else { From 76b70d3c6b3251b5a6352c7242a955818bf152fe Mon Sep 17 00:00:00 2001 From: ktkk Date: Thu, 11 Dec 2025 16:30:51 +0000 Subject: [PATCH 10/17] WIP: implement part 2 --- src/days/day11.zig | 49 +++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/src/days/day11.zig b/src/days/day11.zig index 2525215..b8084d4 100644 --- a/src/days/day11.zig +++ b/src/days/day11.zig @@ -5,6 +5,18 @@ pub const title = "Day 11: Reactor"; pub fn run(allocator: std.mem.Allocator) !void { const input = @embedFile("./input/day11.txt"); //const input = + // \\aaa: you hhh + // \\you: bbb ccc + // \\bbb: ddd eee + // \\ccc: ddd eee fff + // \\ddd: ggg + // \\eee: out + // \\fff: out + // \\ggg: out + // \\hhh: ccc fff iii + // \\iii: out + // ; + //const input = // \\svr: aaa bbb // \\aaa: fft // \\fft: ccc @@ -49,8 +61,11 @@ pub fn run(allocator: std.mem.Allocator) !void { try devices.put(device, outputs_slice); } + var cache: std.StringHashMap(usize) = .init(allocator); + defer cache.deinit(); + var paths_to_out: usize = 0; - visitOutputs("svr", devices, &paths_to_out, false, false); + try visitOutputs("svr", "fft", devices, &cache, &paths_to_out); var buffer: [8]u8 = undefined; var stdout_writer = std.fs.File.stdout().writer(&buffer); @@ -63,30 +78,28 @@ pub fn run(allocator: std.mem.Allocator) !void { fn visitOutputs( start: []const u8, + end: []const u8, devices: std.StringHashMap([][]const u8), - paths_to_out: *usize, - visited_fft: bool, - visited_dac: bool, -) void { + cache: *std.StringHashMap(usize), + paths_to_end: *usize, +) !void { + if (cache.get(start)) |result| { + paths_to_end.* += result; + return; + } + + var paths: usize = 0; const device = devices.get(start); if (device) |outputs| { for (outputs) |output| { - if (std.mem.eql(u8, output, "out")) { - std.debug.print("found out! (fft = {any}, dac = {any})\n", .{visited_fft, visited_dac}); - if (visited_fft and visited_dac) { - std.debug.print("visited fft and dac\n", .{}); - paths_to_out.* += 1; - } - } else if (std.mem.eql(u8, output, "fft")) { - std.debug.print("found fft!\n", .{}); - visitOutputs(output, devices, paths_to_out, true, visited_dac); - } else if (std.mem.eql(u8, output, "dac")) { - std.debug.print("found dac!\n", .{}); - visitOutputs(output, devices, paths_to_out, visited_fft, true); + if (std.mem.eql(u8, output, end)) { + paths += 1; } else { - visitOutputs(output, devices, paths_to_out, visited_fft, visited_dac); + try visitOutputs(output, end, devices, cache, &paths); } } + try cache.put(start, paths); + paths_to_end.* += paths; } else { std.debug.print("device {s} not found\n", .{start}); } From 524b451399f6cd8bcf77db8034b70982c6d77108 Mon Sep 17 00:00:00 2001 From: ktkk Date: Thu, 11 Dec 2025 18:40:52 +0000 Subject: [PATCH 11/17] Finish day11, part 2 --- src/days/day11.zig | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/days/day11.zig b/src/days/day11.zig index b8084d4..5e7686a 100644 --- a/src/days/day11.zig +++ b/src/days/day11.zig @@ -63,15 +63,29 @@ pub fn run(allocator: std.mem.Allocator) !void { var cache: std.StringHashMap(usize) = .init(allocator); defer cache.deinit(); + try cache.ensureTotalCapacity(devices.count()); - var paths_to_out: usize = 0; - try visitOutputs("svr", "fft", devices, &cache, &paths_to_out); + const dac_to_fft = try visitOutputs("dac", "fft", devices, &cache); + const svr_to_fft = try visitOutputs("svr", "fft", devices, &cache); + cache.clearRetainingCapacity(); + + const to_fft = if (dac_to_fft == 0) svr_to_fft else dac_to_fft; + + const dac_start = if (dac_to_fft == 0) "fft" else "svr"; + const end_start = if (dac_to_fft == 0) "dac" else "fft"; + + const to_dac = try visitOutputs(dac_start, "dac", devices, &cache); + cache.clearRetainingCapacity(); + + const to_end = try visitOutputs(end_start, "out", devices, &cache); + + const result = to_fft * to_dac * to_end; var buffer: [8]u8 = undefined; var stdout_writer = std.fs.File.stdout().writer(&buffer); const stdout = &stdout_writer.interface; - try stdout.print("{d}\n", .{paths_to_out}); + try stdout.print("{d}\n", .{result}); try stdout.flush(); } @@ -81,11 +95,9 @@ fn visitOutputs( end: []const u8, devices: std.StringHashMap([][]const u8), cache: *std.StringHashMap(usize), - paths_to_end: *usize, -) !void { +) !usize { if (cache.get(start)) |result| { - paths_to_end.* += result; - return; + return result; } var paths: usize = 0; @@ -95,13 +107,14 @@ fn visitOutputs( if (std.mem.eql(u8, output, end)) { paths += 1; } else { - try visitOutputs(output, end, devices, cache, &paths); + paths += try visitOutputs(output, end, devices, cache); } } try cache.put(start, paths); - paths_to_end.* += paths; + return paths; } else { std.debug.print("device {s} not found\n", .{start}); + return 0; } } From b55a6d61da63d5eab872d4987d515edf808d7015 Mon Sep 17 00:00:00 2001 From: ktkk Date: Fri, 12 Dec 2025 11:02:47 +0000 Subject: [PATCH 12/17] WIP: implement part 1 --- src/days/day12.zig | 170 ++++++- src/days/input/day12.txt | 1030 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 1198 insertions(+), 2 deletions(-) create mode 100755 src/days/input/day12.txt diff --git a/src/days/day12.zig b/src/days/day12.zig index e5f9176..d940d18 100644 --- a/src/days/day12.zig +++ b/src/days/day12.zig @@ -1,7 +1,173 @@ const std = @import("std"); -pub const title = "Day 12"; +pub const title = "Day 12: Christmas Tree Farm"; -pub fn run(_: std.mem.Allocator) !void { +pub fn run(allocator: std.mem.Allocator) !void { + //const input = @embedFile("./input/day12.txt"); + const input = + \\0: + \\### + \\##. + \\##. + \\ + \\1: + \\### + \\##. + \\.## + \\ + \\2: + \\.## + \\### + \\##. + \\ + \\3: + \\##. + \\### + \\##. + \\ + \\4: + \\### + \\#.. + \\### + \\ + \\5: + \\### + \\.#. + \\### + \\ + \\4x4: 0 0 0 0 2 0 + \\12x5: 1 0 1 0 2 2 + \\12x5: 1 0 1 0 3 2 + ; + + var lines = std.mem.tokenizeScalar(u8, input, '\n'); + + var presents: std.ArrayList(Present) = .empty; + defer presents.deinit(allocator); + + var regions: std.ArrayList(Region) = .empty; + defer { + for (regions.items) |region| { + region.deinit(allocator); + } + regions.deinit(allocator); + } + + while (lines.next()) |line| { + var semicolon_pos: usize = 0; + var x_pos: ?usize = null; + for (line, 0..) |c, i| { + switch (c) { + 'x' => x_pos = i, + ':' => { + semicolon_pos = i; + break; + }, + else => {}, + } + } + if (semicolon_pos != 0) { + if (x_pos) |p| { + // region + const width = try std.fmt.parseUnsigned(u8, line[0..p], 10); + const height = try std.fmt.parseUnsigned(u8, line[p + 1..semicolon_pos], 10); + + var required_presents: std.ArrayList(u8) = .empty; + defer required_presents.deinit(allocator); + if (presents.items.len > 0) { + try required_presents.ensureTotalCapacity(allocator, presents.items.len); + } + + var presents_iter = std.mem.tokenizeScalar(u8, line[semicolon_pos + 2..], ' '); + while (presents_iter.next()) |present| { + const amount = try std.fmt.parseUnsigned(u8, present, 10); + try required_presents.append(allocator, amount); + } + + const required_presents_slice = try required_presents.toOwnedSlice(allocator); + errdefer allocator.free(required_presents_slice); + + const region: Region = .{ + .width = width, + .height = height, + .required_presents = required_presents_slice, + }; + try regions.append(allocator, region); + } else { + // present + var present: Present = .{ + .shape = .initEmpty(), + }; + for (0..Present.Width) |y| { + const l = lines.next() orelse unreachable; + for (0..Present.Width) |x| { + if (l[x] == '#') { + present.set(x, y); + } + } + } + try presents.append(allocator, present); + } + } + } + + for (presents.items, 0..) |present, i| { + std.debug.print("{d}:\n{f}\n\n", .{i, present}); + } + + for (regions.items) |region| { + std.debug.print("{f}\n", .{region}); + } } +const Present = struct { + shape: std.bit_set.IntegerBitSet(Width * Width), + + const Width = 3; + + const Self = @This(); + + pub fn format(self: Self, w: *std.Io.Writer) std.Io.Writer.Error!void { + for (0..Width) |y| { + for (0..Width) |x| { + try w.writeByte(if (self.isSet(x, y)) '#' else '.'); + } + if (y < Width - 1) { + try w.writeByte('\n'); + } + } + } + + pub fn set(self: *Self, x: usize, y: usize) void { + const index = (y * Width) + x; + self.shape.set(index); + } + + pub fn isSet(self: Self, x: usize, y: usize) bool { + const index = (y * Width) + x; + return self.shape.isSet(index); + } +}; + +const Region = struct { + width: u8, + height: u8, + required_presents: []u8, + + const Self = @This(); + + pub fn deinit(self: Self, allocator: std.mem.Allocator) void { + allocator.free(self.required_presents); + } + + pub fn format(self: Self, w: *std.Io.Writer) std.Io.Writer.Error!void { + try w.print("{d}x{d}: ", .{self.width, self.height}); + for (self.required_presents, 0..) |present, i| { + try w.print("{d}", .{present}); + if (i < self.required_presents.len - 1) { + try w.writeByte(' '); + } + } + } +}; + diff --git a/src/days/input/day12.txt b/src/days/input/day12.txt new file mode 100755 index 0000000..6b6eac1 --- /dev/null +++ b/src/days/input/day12.txt @@ -0,0 +1,1030 @@ +0: +..# +.## +### + +1: +### +.## +.## + +2: +..# +.## +##. + +3: +##. +.## +### + +4: +### +#.# +#.# + +5: +### +.#. +### + +46x37: 23 26 23 34 38 36 +46x38: 47 53 50 49 36 36 +38x41: 28 24 30 26 22 26 +49x43: 48 59 49 63 49 54 +49x41: 48 50 45 59 54 51 +49x50: 60 60 60 70 60 66 +50x41: 55 43 52 54 49 63 +35x45: 41 46 31 47 37 38 +45x46: 51 47 59 61 51 51 +36x48: 47 57 28 37 47 46 +38x47: 57 36 50 48 35 52 +44x39: 32 31 34 32 29 23 +38x45: 33 26 32 40 23 25 +37x45: 46 40 29 38 57 43 +46x41: 33 36 31 34 25 36 +37x44: 39 44 34 41 40 50 +46x50: 50 64 45 58 72 60 +40x40: 26 36 28 31 24 23 +48x49: 55 56 70 67 63 53 +37x38: 25 33 20 21 17 27 +42x35: 31 45 39 37 34 40 +45x47: 53 58 63 52 46 56 +49x49: 56 60 65 60 64 65 +43x43: 52 45 42 52 46 47 +43x41: 48 45 32 43 46 54 +38x48: 43 38 49 46 61 44 +35x46: 34 59 31 34 42 44 +37x45: 40 48 42 41 34 51 +38x36: 40 26 34 35 38 38 +47x49: 54 54 56 65 68 56 +49x45: 37 36 42 48 38 38 +43x39: 46 44 47 40 47 36 +43x37: 49 38 36 35 45 42 +35x45: 21 23 28 32 30 30 +38x43: 25 35 26 29 27 26 +44x45: 51 50 62 44 58 43 +50x43: 49 59 69 61 52 44 +40x49: 44 59 58 52 41 49 +42x50: 59 52 46 56 57 52 +38x43: 33 25 32 24 34 19 +36x44: 43 51 36 35 35 43 +50x47: 46 39 23 48 41 43 +39x46: 43 48 43 53 41 47 +41x45: 45 55 52 42 44 47 +35x36: 34 26 34 32 41 28 +40x48: 46 45 55 50 52 49 +39x45: 42 55 38 43 36 54 +41x45: 42 49 42 45 51 53 +48x49: 64 58 65 68 44 65 +38x41: 25 27 20 15 31 38 +46x41: 57 45 50 41 52 47 +44x46: 49 49 47 50 59 56 +47x45: 49 64 62 43 54 55 +37x41: 29 22 24 30 22 28 +50x36: 43 58 36 54 36 47 +37x41: 41 38 42 29 38 47 +43x47: 47 55 53 53 43 60 +38x50: 36 29 37 27 34 29 +48x47: 41 36 41 43 37 42 +38x45: 39 38 48 51 43 45 +43x49: 36 33 47 39 43 25 +48x50: 53 67 57 49 74 67 +37x48: 28 29 35 32 27 40 +48x47: 52 61 56 70 59 48 +41x43: 36 47 44 59 44 40 +35x40: 34 45 35 35 35 31 +48x46: 36 40 51 36 51 26 +49x47: 59 62 53 67 53 59 +38x40: 26 26 25 26 27 25 +42x50: 46 32 36 39 40 31 +47x50: 62 57 70 70 55 51 +45x41: 33 52 47 51 56 43 +49x35: 36 56 48 41 47 36 +45x44: 43 50 48 61 52 49 +48x47: 31 35 49 35 35 54 +44x35: 22 40 15 29 24 24 +35x36: 16 21 23 25 22 24 +36x45: 56 44 33 34 40 42 +44x44: 53 51 54 43 51 48 +48x36: 32 31 39 25 41 23 +44x42: 40 36 33 23 36 28 +41x43: 28 35 24 34 29 32 +41x37: 26 27 27 33 23 19 +41x47: 40 21 34 29 33 38 +49x35: 39 39 46 45 52 43 +44x39: 39 29 28 27 21 38 +35x37: 41 28 28 38 33 31 +44x49: 33 51 27 40 31 42 +50x45: 49 39 30 35 47 39 +46x49: 35 41 38 46 35 44 +40x50: 65 50 44 45 39 65 +38x44: 21 24 41 22 32 27 +45x45: 43 53 46 53 61 53 +43x46: 45 48 45 50 55 59 +47x41: 42 52 44 45 47 64 +46x39: 42 33 27 38 29 26 +46x43: 63 49 49 46 44 55 +40x35: 34 31 38 48 29 36 +41x40: 27 29 33 23 24 32 +47x36: 32 21 34 35 32 26 +49x49: 48 41 47 40 35 44 +36x38: 28 26 26 24 20 20 +39x35: 33 42 25 29 45 33 +48x47: 54 68 52 57 63 51 +36x42: 43 38 47 32 39 37 +47x41: 33 40 35 37 23 27 +47x37: 63 45 39 38 42 42 +42x42: 31 60 47 49 42 41 +36x44: 54 48 30 33 39 39 +46x42: 31 34 38 27 46 33 +47x43: 58 47 62 49 49 50 +38x47: 51 37 39 53 48 46 +41x46: 48 57 51 58 43 34 +36x42: 31 34 46 42 40 41 +38x49: 56 48 41 42 47 52 +43x35: 23 28 29 28 30 15 +47x38: 36 41 47 47 53 50 +44x48: 59 56 54 62 55 40 +40x47: 38 30 28 41 32 26 +44x41: 46 60 37 43 45 44 +42x45: 42 38 27 32 37 34 +37x40: 44 38 31 37 40 37 +39x50: 29 49 29 34 27 39 +41x35: 33 33 31 36 49 37 +43x38: 17 27 28 33 33 30 +47x38: 36 26 35 30 28 25 +43x50: 51 58 60 51 54 58 +42x41: 52 42 50 40 36 48 +41x41: 30 28 27 35 27 22 +45x36: 49 46 33 34 32 54 +38x37: 23 21 29 20 22 28 +42x42: 38 33 30 31 29 34 +50x45: 63 71 60 50 41 63 +42x37: 44 38 40 37 37 44 +40x41: 46 34 49 47 34 45 +38x38: 45 36 31 37 39 34 +40x38: 23 31 22 25 34 20 +49x44: 31 40 37 38 36 41 +38x50: 35 28 37 32 26 33 +38x38: 31 35 42 36 45 34 +42x48: 45 39 30 31 38 41 +36x46: 24 24 25 22 36 48 +45x48: 75 56 61 51 46 48 +42x37: 39 30 46 37 50 39 +44x42: 43 31 27 32 31 31 +40x39: 46 38 36 41 39 40 +39x47: 47 45 46 49 51 44 +45x47: 37 47 33 38 33 37 +37x42: 28 24 34 27 33 22 +39x40: 32 46 36 33 37 54 +41x50: 69 48 39 57 59 42 +46x48: 64 59 42 68 51 53 +47x44: 57 52 57 54 36 64 +47x47: 50 62 60 68 46 54 +38x44: 38 49 43 39 42 46 +49x42: 48 45 62 50 55 59 +37x38: 26 15 26 35 16 26 +35x42: 41 33 38 40 32 43 +47x48: 70 62 47 48 60 59 +39x39: 51 36 32 42 38 35 +46x35: 50 36 44 38 37 45 +43x37: 20 27 34 30 27 30 +39x47: 41 46 45 51 44 54 +36x49: 37 31 28 31 30 34 +48x36: 33 48 42 47 54 40 +43x38: 28 31 27 29 31 22 +38x38: 38 35 35 33 49 32 +40x43: 21 31 32 35 36 27 +41x36: 27 32 24 22 18 33 +48x49: 54 49 59 69 80 50 +44x41: 41 40 46 59 38 53 +49x49: 62 61 56 76 55 58 +37x48: 35 28 42 30 33 24 +48x39: 31 41 30 37 34 35 +41x44: 58 36 38 47 53 45 +44x50: 39 41 45 38 31 29 +50x38: 37 42 63 56 49 48 +44x40: 43 47 56 43 38 47 +39x50: 55 63 47 33 43 59 +45x36: 25 39 32 25 17 41 +42x48: 38 38 43 29 34 41 +46x35: 31 34 23 28 25 24 +43x35: 37 35 37 47 37 38 +45x45: 48 30 35 36 41 35 +42x38: 22 31 28 21 37 29 +48x47: 49 37 29 49 34 42 +42x41: 36 53 47 41 48 40 +35x38: 24 23 23 27 20 14 +41x37: 40 40 39 44 31 40 +42x37: 30 21 40 36 23 18 +41x42: 30 42 50 49 55 39 +36x41: 42 31 42 46 36 32 +43x38: 27 28 35 31 24 22 +37x41: 30 28 30 18 24 25 +45x38: 47 37 45 36 38 61 +48x42: 41 33 45 32 38 35 +37x39: 23 23 28 31 26 25 +49x36: 28 28 38 33 36 28 +37x48: 22 30 33 30 32 44 +50x47: 70 54 56 73 48 61 +46x42: 53 50 60 54 45 39 +48x49: 65 66 51 65 54 59 +36x40: 52 39 47 33 31 25 +45x43: 39 45 28 30 30 37 +35x42: 37 44 37 37 42 29 +40x43: 34 34 25 31 26 31 +45x43: 43 36 35 36 23 37 +47x37: 51 42 42 45 42 46 +42x44: 25 37 21 41 39 32 +43x49: 47 67 59 59 45 48 +39x50: 41 33 35 31 32 36 +39x39: 28 24 27 30 34 26 +36x42: 38 35 40 34 47 39 +43x37: 26 29 24 25 35 28 +43x46: 49 53 56 45 55 48 +39x39: 16 30 29 29 37 28 +40x39: 24 31 27 24 20 42 +38x44: 39 33 54 45 39 50 +46x48: 48 53 71 57 55 59 +46x47: 66 70 57 38 55 49 +49x42: 52 48 57 49 60 52 +45x44: 54 44 49 56 57 45 +41x35: 47 33 35 39 36 32 +47x44: 45 53 55 60 58 47 +47x35: 18 26 27 38 33 23 +45x37: 34 50 53 35 44 42 +37x40: 42 44 29 43 30 38 +36x35: 38 37 33 29 33 25 +38x44: 36 53 41 46 33 47 +40x40: 42 43 43 32 44 43 +41x43: 28 32 29 23 33 36 +45x50: 53 58 59 63 66 47 +44x46: 46 49 53 49 55 59 +41x35: 41 28 45 38 38 34 +43x47: 37 41 36 31 33 31 +46x44: 44 63 40 54 56 50 +46x41: 57 53 43 33 52 52 +38x47: 46 36 42 54 52 44 +42x47: 31 37 41 29 32 40 +36x35: 21 30 22 17 21 20 +47x49: 67 54 67 61 58 51 +39x44: 48 50 44 48 36 39 +49x38: 30 34 38 28 30 32 +49x38: 52 54 47 50 46 38 +44x48: 49 66 63 52 52 45 +45x39: 46 43 40 52 40 48 +40x48: 27 41 33 37 33 36 +37x44: 30 29 27 31 23 28 +44x40: 36 48 35 46 53 49 +41x36: 31 39 43 42 41 32 +42x46: 47 43 46 52 61 47 +42x36: 38 49 32 39 39 34 +42x38: 46 25 36 43 52 43 +42x46: 48 54 35 37 66 53 +39x42: 32 35 33 27 31 23 +43x50: 54 52 52 72 46 54 +47x36: 23 37 31 29 30 29 +36x45: 32 43 52 28 57 39 +50x40: 40 57 54 50 64 42 +43x46: 33 37 36 30 35 39 +49x43: 47 28 38 44 25 41 +38x38: 30 33 21 47 37 49 +43x36: 45 40 42 40 39 34 +44x41: 29 35 38 17 36 26 +50x40: 33 32 24 42 31 45 +43x40: 28 26 34 35 30 29 +45x40: 47 49 48 43 37 54 +45x47: 65 58 53 49 43 59 +41x46: 62 54 47 43 53 33 +47x41: 63 47 68 45 39 42 +38x46: 49 40 42 54 37 47 +47x39: 33 32 33 35 30 32 +45x38: 29 31 32 33 31 23 +40x42: 40 36 49 34 41 60 +50x35: 39 41 49 42 41 58 +44x38: 48 45 49 48 38 32 +44x40: 47 43 47 44 53 38 +46x46: 57 53 54 50 60 52 +50x45: 39 37 37 39 53 35 +48x45: 59 44 59 69 45 58 +47x46: 57 63 55 57 49 52 +48x38: 52 48 52 53 30 48 +43x37: 46 43 34 31 48 42 +40x49: 49 49 45 48 47 62 +46x48: 65 69 60 54 60 34 +43x38: 26 27 26 21 28 39 +36x44: 35 36 44 43 38 48 +41x42: 32 47 63 40 31 56 +36x45: 36 47 39 48 41 37 +48x39: 43 38 38 25 30 33 +48x36: 47 44 43 47 41 44 +37x46: 51 36 39 35 52 49 +35x43: 16 23 36 28 23 27 +36x46: 39 47 58 30 45 40 +44x35: 34 38 34 44 35 50 +44x37: 28 43 43 37 52 46 +38x40: 19 22 28 27 27 32 +36x44: 29 25 35 30 31 18 +40x47: 57 56 52 35 54 38 +35x49: 36 28 25 24 33 29 +35x42: 38 37 33 41 41 35 +48x49: 56 60 62 48 68 68 +42x50: 31 36 51 41 32 32 +47x36: 25 32 36 29 29 28 +50x36: 34 23 42 30 30 32 +45x37: 35 18 29 32 36 30 +43x43: 37 29 24 32 38 36 +42x42: 26 24 28 40 41 36 +47x37: 57 42 43 44 43 40 +41x40: 53 42 38 50 32 38 +37x37: 35 32 43 29 39 35 +48x45: 32 36 51 41 34 46 +47x38: 52 45 46 41 52 40 +40x38: 16 29 19 29 34 28 +42x40: 37 24 28 25 38 30 +47x46: 59 46 50 54 62 61 +38x35: 27 31 45 35 30 39 +47x39: 47 41 36 58 47 50 +50x40: 53 49 57 44 53 54 +37x47: 25 23 31 38 36 26 +37x42: 35 46 44 40 37 38 +49x46: 68 49 74 53 48 61 +38x48: 30 39 34 21 31 37 +47x48: 40 44 38 38 43 37 +49x48: 33 41 54 47 42 38 +42x49: 32 31 38 42 41 39 +35x47: 49 56 38 31 33 46 +39x47: 42 49 59 47 40 48 +35x41: 37 31 44 28 43 40 +47x39: 44 44 62 30 53 53 +47x41: 43 44 50 67 46 46 +43x44: 28 30 29 39 32 37 +43x48: 55 62 66 52 41 46 +49x41: 26 36 40 45 33 27 +43x50: 45 66 70 59 52 42 +40x39: 47 42 32 41 44 33 +44x37: 40 25 23 26 25 29 +43x46: 36 55 56 72 37 48 +48x47: 47 57 59 59 63 61 +42x49: 52 58 50 59 46 51 +42x37: 37 37 47 38 44 38 +35x39: 41 35 28 38 29 38 +43x43: 35 27 34 38 33 29 +48x48: 51 60 61 62 57 63 +43x38: 32 29 28 29 25 25 +47x44: 39 25 43 35 31 36 +44x50: 28 26 43 41 42 43 +42x43: 28 32 32 37 38 29 +48x44: 69 57 49 48 58 45 +36x39: 37 29 41 38 25 48 +40x37: 30 30 25 29 22 19 +39x39: 34 25 32 27 25 25 +43x36: 25 23 32 26 32 30 +50x36: 52 53 50 43 44 37 +48x44: 41 32 45 47 37 21 +40x47: 32 34 37 28 30 33 +41x36: 42 38 48 49 38 16 +45x39: 32 43 31 25 32 31 +41x49: 42 36 32 36 29 33 +36x41: 36 43 37 35 35 41 +46x42: 44 48 64 50 54 41 +37x44: 31 32 26 26 34 18 +48x40: 58 50 39 46 45 56 +50x48: 69 69 60 53 57 62 +39x46: 34 38 30 32 31 29 +43x50: 46 63 59 57 50 56 +50x41: 44 29 40 27 33 34 +36x35: 17 26 20 18 28 22 +44x40: 54 34 40 51 45 47 +46x45: 30 42 46 32 39 35 +43x39: 30 27 26 26 29 43 +47x43: 41 58 50 52 60 48 +38x39: 31 23 24 23 30 25 +35x38: 26 39 38 37 29 36 +36x42: 33 37 38 40 39 45 +40x44: 28 53 39 42 54 51 +40x44: 35 31 24 31 28 33 +37x46: 34 31 27 23 27 38 +50x41: 45 43 47 47 57 74 +37x44: 46 48 34 36 42 43 +38x39: 25 50 33 41 32 44 +47x42: 31 48 35 30 29 37 +42x35: 29 19 29 35 22 20 +44x44: 33 33 33 31 36 29 +39x35: 28 21 24 25 22 23 +38x45: 28 29 33 25 32 32 +46x49: 57 48 62 60 64 57 +40x46: 21 41 34 25 36 38 +50x46: 48 32 44 34 38 44 +46x42: 47 59 45 47 52 46 +46x43: 36 37 40 37 29 31 +41x40: 25 35 30 26 24 29 +49x43: 48 64 38 60 48 61 +39x45: 42 49 56 44 40 42 +50x48: 70 68 59 57 60 56 +41x47: 41 50 51 55 46 53 +45x43: 48 57 50 49 48 46 +35x36: 31 30 46 31 31 29 +40x40: 31 38 44 41 52 40 +44x45: 41 58 46 60 46 51 +44x37: 36 35 49 48 40 44 +46x41: 46 43 44 51 52 53 +43x49: 40 42 35 37 41 28 +49x35: 36 35 28 32 21 23 +38x37: 47 33 28 44 28 36 +49x42: 61 56 49 54 41 56 +38x43: 43 45 46 37 42 40 +44x44: 50 50 42 62 54 38 +41x39: 27 31 32 21 29 29 +39x39: 21 33 36 33 22 24 +42x38: 37 31 50 50 33 47 +41x37: 41 37 42 43 35 37 +35x47: 38 48 46 36 46 40 +43x48: 44 33 30 32 37 47 +50x49: 71 59 58 63 64 62 +41x39: 44 38 39 42 32 51 +40x44: 37 39 26 27 27 26 +46x48: 33 43 40 42 46 36 +42x50: 39 27 41 34 50 33 +47x48: 66 57 52 58 57 57 +44x35: 31 14 22 33 31 22 +44x35: 38 40 43 33 43 41 +48x48: 39 42 55 30 53 37 +38x40: 27 29 24 27 22 27 +38x45: 48 43 37 45 46 43 +35x47: 47 47 60 41 33 31 +36x50: 44 41 50 52 41 50 +48x41: 51 52 53 41 54 53 +44x47: 38 53 55 59 59 53 +48x38: 38 27 22 44 40 21 +41x40: 41 41 34 49 39 46 +44x37: 29 34 21 25 26 32 +43x44: 28 33 39 30 34 31 +50x37: 44 59 49 49 33 51 +47x49: 41 69 62 55 70 56 +49x46: 37 38 45 40 45 34 +37x35: 29 26 19 23 13 21 +37x50: 31 35 27 43 36 20 +49x44: 41 57 59 52 65 57 +45x49: 54 62 63 48 55 59 +41x40: 36 46 43 51 39 37 +48x50: 41 35 46 45 32 57 +38x45: 33 25 23 32 33 33 +43x45: 44 66 49 51 46 41 +50x37: 38 25 32 38 26 32 +39x45: 50 38 28 53 44 53 +43x38: 36 25 29 24 27 27 +50x40: 43 49 63 53 47 55 +42x40: 26 29 29 31 37 29 +35x46: 37 27 15 29 31 26 +47x50: 57 65 59 53 62 65 +47x37: 30 28 22 27 42 31 +45x44: 45 39 51 69 54 46 +39x49: 33 42 34 28 38 32 +44x48: 30 42 32 41 37 41 +45x46: 42 48 49 64 52 61 +47x37: 31 29 28 24 33 35 +49x43: 41 42 34 39 30 38 +37x39: 27 18 30 33 24 24 +45x41: 45 45 45 46 46 56 +45x50: 40 45 46 35 31 43 +38x48: 48 40 33 41 60 55 +45x49: 43 41 35 34 38 48 +50x42: 39 53 63 51 60 58 +40x47: 59 52 41 49 40 48 +38x40: 25 29 25 27 26 23 +47x48: 47 47 41 35 37 32 +37x36: 16 30 20 25 32 20 +46x46: 59 53 67 41 64 46 +36x48: 44 40 44 43 62 33 +50x40: 45 43 55 44 61 60 +49x46: 54 63 67 56 52 57 +35x48: 31 48 39 50 44 44 +39x38: 44 33 41 39 36 37 +49x44: 54 59 46 60 50 60 +44x39: 27 33 37 33 29 23 +40x44: 23 34 27 36 34 27 +36x41: 24 27 29 22 31 23 +47x40: 52 44 52 58 48 37 +38x45: 33 34 34 23 35 20 +39x36: 34 23 29 24 24 21 +35x49: 39 30 25 22 28 32 +43x50: 50 65 61 46 53 57 +49x43: 35 39 38 37 40 35 +37x44: 27 30 30 27 21 33 +41x41: 20 24 35 32 23 35 +45x45: 30 36 41 40 42 35 +40x49: 35 34 24 35 50 29 +48x43: 38 41 38 40 30 37 +46x43: 53 47 40 69 48 45 +42x44: 53 48 49 39 58 39 +37x44: 28 29 39 23 27 22 +39x47: 57 51 62 46 34 38 +40x36: 36 42 34 29 41 39 +42x38: 35 26 29 21 30 26 +42x47: 31 39 41 35 27 36 +40x35: 32 35 29 46 35 36 +50x40: 42 25 37 35 35 34 +48x43: 40 31 45 28 37 42 +50x49: 44 39 45 41 47 39 +40x45: 33 23 31 32 42 34 +44x41: 31 28 25 28 35 35 +48x50: 66 56 61 60 61 66 +48x42: 44 49 43 51 57 63 +42x50: 69 63 59 45 49 42 +49x40: 47 52 52 42 57 52 +42x41: 19 27 34 35 36 31 +38x39: 31 37 40 46 36 38 +44x36: 41 31 51 41 42 41 +40x44: 37 28 23 27 29 37 +50x49: 38 42 41 48 40 47 +48x38: 31 46 45 24 22 24 +44x46: 44 34 35 35 28 34 +49x38: 34 57 45 56 50 42 +47x46: 65 57 51 54 59 47 +41x49: 42 38 30 36 26 35 +40x45: 49 60 47 40 35 47 +45x43: 33 31 36 35 43 32 +50x43: 60 53 52 56 55 55 +38x41: 26 19 28 34 22 27 +35x42: 21 14 20 33 39 27 +48x43: 54 53 46 58 56 49 +39x40: 42 38 41 43 35 42 +36x35: 31 34 26 38 35 28 +36x36: 28 27 48 41 28 31 +37x40: 35 42 33 40 32 44 +35x36: 24 18 28 24 21 17 +43x41: 47 42 36 46 43 55 +46x39: 50 34 43 54 39 56 +40x35: 32 28 21 28 17 17 +46x36: 54 36 44 37 44 42 +37x47: 35 49 47 49 33 54 +45x35: 39 37 56 42 39 34 +35x41: 20 29 24 25 19 25 +36x48: 56 37 52 46 34 45 +44x47: 50 50 56 55 53 55 +41x42: 45 48 50 30 46 48 +35x46: 32 42 53 30 43 50 +38x36: 35 43 29 36 27 39 +38x41: 20 27 22 33 23 30 +41x49: 53 48 56 41 59 54 +37x40: 30 37 39 36 37 48 +38x42: 53 49 29 33 43 37 +43x40: 52 40 37 49 45 41 +38x37: 31 39 36 32 37 41 +37x37: 21 27 21 24 27 24 +50x41: 33 20 38 35 34 47 +42x49: 47 61 63 47 51 50 +39x41: 43 43 36 39 39 45 +42x38: 48 27 41 39 39 53 +46x36: 32 29 40 25 31 22 +35x46: 35 21 29 24 33 23 +35x41: 29 33 40 33 43 43 +37x36: 20 20 32 29 17 25 +44x39: 42 53 48 57 28 37 +44x46: 40 35 46 25 36 28 +45x35: 37 43 40 50 34 38 +47x49: 43 48 35 33 35 45 +50x42: 52 61 60 51 45 56 +43x36: 38 38 46 33 37 48 +48x38: 46 44 44 53 45 48 +44x35: 27 26 24 27 24 26 +36x49: 33 37 36 25 24 37 +48x47: 28 35 38 50 37 52 +40x49: 33 36 33 40 36 29 +40x50: 42 34 30 33 32 37 +40x36: 24 21 29 31 21 30 +43x44: 38 34 29 34 26 34 +40x45: 49 45 47 43 40 54 +46x44: 48 60 41 54 41 64 +41x44: 28 34 30 31 29 29 +48x48: 62 62 66 55 62 50 +37x50: 37 31 37 29 21 36 +35x38: 36 32 33 30 36 38 +41x38: 46 47 40 40 34 34 +46x50: 51 54 62 53 64 70 +38x48: 34 27 33 34 32 31 +42x36: 42 26 55 36 35 44 +35x48: 31 32 26 26 33 27 +35x38: 22 23 24 15 26 22 +41x39: 40 31 41 46 43 45 +48x44: 53 53 54 49 61 55 +44x36: 46 36 35 41 39 46 +46x40: 23 28 41 31 39 33 +39x45: 26 42 31 22 34 39 +42x42: 33 66 53 40 38 42 +37x50: 55 43 44 48 37 58 +47x42: 36 25 42 34 37 36 +43x47: 51 55 55 45 55 51 +47x46: 33 39 29 31 39 53 +49x36: 53 54 49 49 35 34 +45x43: 33 33 32 33 39 40 +40x36: 27 26 19 30 21 32 +43x39: 27 25 31 31 30 37 +35x42: 28 19 34 26 21 25 +44x45: 48 52 63 44 45 56 +42x35: 32 42 29 35 49 36 +40x40: 24 27 28 28 31 31 +43x42: 31 38 24 39 31 33 +35x41: 43 34 33 30 40 41 +45x41: 41 42 60 52 53 39 +44x49: 35 35 28 32 49 44 +38x42: 35 25 32 32 23 21 +47x40: 44 49 42 52 53 47 +40x38: 30 24 20 31 33 18 +46x43: 52 54 52 41 59 47 +35x39: 35 33 34 42 35 31 +39x46: 49 42 50 51 40 46 +41x46: 49 36 57 54 40 57 +35x47: 52 38 47 44 39 36 +37x45: 31 22 30 32 39 26 +48x39: 34 68 50 43 49 43 +49x38: 43 61 47 39 55 41 +47x42: 50 54 41 51 60 45 +36x45: 28 31 26 32 26 37 +42x46: 53 52 43 51 53 44 +36x38: 26 27 22 24 18 27 +50x37: 31 35 20 37 37 31 +44x44: 47 48 44 44 58 55 +36x50: 40 29 28 28 37 30 +48x39: 52 51 42 50 35 57 +48x48: 64 59 51 52 67 60 +39x47: 49 49 45 45 38 56 +46x46: 36 51 31 37 32 37 +47x43: 23 38 38 27 42 42 +38x35: 35 36 30 42 34 27 +39x50: 22 38 35 33 36 44 +41x49: 49 28 36 29 32 34 +40x40: 31 31 28 27 28 23 +44x48: 56 55 63 48 46 60 +35x39: 26 25 27 26 18 20 +42x48: 35 35 40 37 38 38 +45x40: 37 45 50 45 33 67 +43x37: 42 47 37 37 45 36 +45x41: 50 39 49 51 43 53 +47x50: 59 64 47 56 71 61 +42x38: 49 44 44 46 33 32 +41x41: 27 52 30 47 49 48 +41x36: 39 27 33 36 41 50 +46x36: 36 30 33 31 17 32 +43x35: 39 29 35 35 48 45 +38x36: 25 25 30 17 23 24 +39x43: 39 31 18 33 31 29 +38x44: 48 37 42 47 47 37 +37x38: 29 35 10 20 28 21 +35x41: 35 43 34 38 33 37 +39x36: 28 46 29 35 36 39 +46x44: 49 57 65 45 42 57 +43x35: 32 43 42 37 41 37 +35x39: 34 27 31 41 40 36 +37x37: 26 23 28 25 21 21 +35x47: 36 43 34 42 46 49 +43x36: 36 41 44 44 39 35 +46x38: 26 36 31 28 31 28 +42x44: 49 52 62 39 47 40 +50x37: 24 44 21 26 40 36 +45x42: 53 51 36 49 47 52 +44x36: 23 29 35 29 26 25 +36x50: 43 50 40 46 50 46 +37x47: 31 30 25 29 28 36 +49x46: 54 35 43 42 35 31 +40x36: 23 27 25 26 23 32 +49x48: 42 61 69 70 64 56 +38x49: 61 47 45 47 47 41 +47x40: 27 25 29 34 40 39 +35x38: 24 30 17 21 22 18 +42x39: 48 38 38 50 49 29 +48x37: 39 40 31 26 34 21 +47x50: 52 33 32 42 32 49 +50x42: 53 59 49 48 50 63 +45x44: 22 45 37 27 42 36 +39x39: 35 40 37 44 33 44 +44x49: 63 50 48 59 52 59 +35x48: 33 24 26 29 33 31 +42x41: 27 32 27 33 33 29 +48x41: 33 26 40 33 44 32 +39x45: 37 46 38 46 56 44 +41x42: 68 36 35 46 49 32 +50x40: 40 37 28 42 27 34 +43x46: 36 53 56 43 63 53 +44x41: 28 36 28 22 41 27 +50x35: 25 21 42 32 27 29 +41x48: 56 50 55 55 41 48 +39x48: 57 39 49 45 48 52 +36x36: 18 25 19 28 32 21 +40x40: 49 36 46 38 36 44 +43x37: 33 43 44 46 40 39 +38x38: 41 37 48 28 36 36 +42x40: 50 33 34 43 58 39 +45x41: 20 30 41 39 33 31 +39x40: 37 51 40 32 44 36 +37x39: 37 32 32 43 38 39 +36x46: 33 23 34 20 31 38 +47x48: 42 46 33 40 45 33 +41x44: 31 30 27 26 34 33 +47x43: 60 49 54 43 59 48 +39x36: 43 35 49 28 36 30 +50x43: 39 27 39 41 43 35 +50x43: 58 50 46 62 61 52 +45x38: 50 34 53 45 48 37 +44x40: 39 28 31 24 24 35 +46x44: 53 57 59 46 56 43 +44x35: 35 46 41 38 44 33 +42x44: 47 49 56 45 41 49 +35x39: 26 27 49 45 29 37 +36x45: 36 47 43 46 45 32 +46x35: 33 24 22 36 32 18 +39x45: 35 45 49 50 43 48 +36x48: 48 46 46 39 44 44 +43x45: 54 43 40 59 48 52 +47x35: 34 42 41 51 42 42 +45x41: 34 61 47 64 44 32 +39x42: 21 41 35 26 23 35 +38x50: 42 56 60 48 38 51 +38x45: 44 49 42 40 50 38 +45x43: 32 49 48 48 70 48 +46x44: 24 25 42 47 35 37 +43x36: 33 32 45 50 40 39 +47x45: 41 36 31 39 34 43 +49x43: 40 36 40 39 35 33 +38x35: 42 37 34 21 34 38 +39x50: 31 35 35 35 35 36 +48x48: 54 53 66 56 63 64 +43x37: 37 43 36 42 46 39 +37x46: 31 28 26 34 31 29 +43x35: 29 26 24 28 25 22 +45x41: 36 39 28 27 31 33 +48x46: 38 32 52 30 41 46 +42x47: 45 60 47 51 52 47 +49x36: 46 45 57 41 37 49 +41x38: 27 30 25 23 25 26 +46x46: 63 51 36 63 58 51 +41x39: 27 23 22 29 29 39 +47x38: 46 48 52 39 47 45 +43x38: 36 48 43 44 43 37 +37x39: 30 26 21 31 29 18 +47x42: 53 64 42 59 35 49 +50x36: 37 28 26 36 36 29 +44x43: 37 37 19 42 26 34 +38x49: 57 45 47 46 43 50 +38x39: 36 36 41 35 37 44 +38x38: 37 35 42 37 32 41 +36x37: 45 37 32 36 28 28 +37x39: 34 35 37 38 48 30 +37x47: 35 29 24 33 27 31 +47x35: 25 23 26 34 31 26 +35x44: 22 21 22 26 40 23 +38x43: 40 31 51 43 39 50 +46x45: 32 33 33 38 45 43 +38x49: 48 38 52 47 47 56 +45x36: 44 44 35 26 47 52 +42x37: 33 25 21 27 33 28 +45x37: 45 42 44 39 52 35 +46x38: 36 53 52 41 36 52 +45x45: 58 38 49 63 52 52 +47x37: 28 38 30 25 25 34 +39x40: 57 36 37 39 43 30 +45x46: 61 54 47 50 43 63 +41x42: 25 36 29 26 29 36 +49x50: 54 39 46 42 37 38 +46x38: 57 38 66 47 32 37 +43x35: 28 22 21 22 29 31 +45x47: 40 35 31 38 33 47 +49x47: 56 57 58 68 57 58 +42x48: 34 29 35 43 40 42 +50x39: 55 52 47 53 47 46 +50x50: 45 47 37 46 38 42 +36x40: 25 24 28 25 27 27 +48x40: 56 44 40 43 61 50 +48x39: 26 36 38 27 42 38 +48x45: 33 29 30 52 48 48 +48x41: 34 26 39 32 38 38 +40x44: 48 46 50 40 41 48 +43x47: 26 35 39 38 37 34 +43x38: 44 21 34 21 21 26 +35x38: 22 21 16 29 22 21 +45x39: 31 28 34 28 48 26 +43x39: 35 33 21 32 31 29 +40x44: 35 35 38 19 24 31 +37x50: 50 46 43 55 39 51 +41x44: 33 36 34 26 27 25 +42x48: 49 44 62 56 46 56 +40x45: 40 44 52 45 51 46 +47x49: 43 33 39 45 39 40 +48x39: 47 43 61 42 49 50 +47x39: 36 25 29 38 30 36 +48x40: 59 63 42 40 38 53 +46x44: 49 50 51 59 54 48 +46x44: 45 56 53 51 51 55 +46x39: 33 24 34 43 24 37 +36x50: 40 50 52 53 42 41 +47x48: 71 49 71 52 51 59 +48x42: 38 44 44 22 34 41 +39x46: 30 33 28 46 26 32 +37x40: 40 39 37 37 33 42 +44x44: 43 29 44 37 23 20 +41x49: 56 52 48 51 59 43 +43x43: 32 35 35 27 26 41 +36x37: 26 32 45 37 39 28 +44x50: 44 30 38 36 43 33 +47x48: 49 68 50 57 53 67 +38x47: 50 41 50 45 41 50 +48x36: 41 49 52 47 31 48 +42x48: 37 42 25 42 36 41 +35x50: 53 57 39 42 34 44 +50x35: 58 36 51 32 55 41 +42x35: 38 37 43 38 44 28 +44x39: 39 50 38 58 39 38 +38x43: 30 44 46 44 38 49 +36x40: 34 34 43 39 39 34 +36x38: 25 37 38 34 40 36 +47x35: 28 29 26 27 28 27 +43x37: 47 43 31 44 33 45 +39x45: 33 32 25 35 35 34 +46x49: 25 50 53 41 34 36 +41x38: 38 46 34 48 35 37 +39x43: 30 31 28 32 29 32 +40x35: 48 24 34 33 40 38 +45x48: 63 60 57 53 43 58 +47x46: 59 55 43 63 53 57 +41x39: 32 43 44 38 45 44 +41x48: 45 42 56 51 54 56 +43x47: 67 47 47 42 53 56 +35x40: 36 28 37 48 32 35 +48x37: 41 21 42 28 30 30 +40x35: 32 31 36 35 35 46 +42x35: 44 40 33 33 40 36 +38x48: 19 36 31 38 29 39 +48x35: 39 39 39 50 43 47 +47x39: 52 47 44 44 55 40 +48x45: 38 34 36 40 52 40 +43x40: 34 34 32 18 26 37 +40x43: 46 49 43 51 36 40 +35x48: 32 28 27 30 32 26 +48x48: 42 42 46 44 48 33 +47x46: 51 47 62 62 67 45 +36x40: 20 27 27 27 25 30 +40x48: 34 46 47 23 26 31 +41x41: 48 40 48 43 42 40 +48x47: 35 31 53 46 32 43 +42x38: 26 30 27 27 21 36 +38x46: 42 28 27 25 27 30 +36x38: 21 23 26 28 28 17 +47x37: 49 49 40 49 44 36 +48x44: 52 63 58 44 51 58 +37x45: 27 27 25 29 40 32 +46x37: 21 37 35 36 22 28 +38x43: 37 26 27 22 34 22 +41x39: 28 29 30 24 33 25 +49x37: 34 28 29 30 35 35 +39x40: 45 40 44 33 40 40 +45x38: 33 25 37 22 33 30 +44x37: 29 31 26 28 26 28 +44x47: 30 41 34 44 42 18 +39x36: 28 30 23 24 28 23 +37x46: 27 32 37 31 24 29 +43x45: 51 47 46 58 47 48 +48x41: 48 56 45 50 52 50 +36x41: 29 26 20 27 26 27 +44x35: 42 33 31 45 39 45 +44x42: 45 47 46 56 41 49 +48x46: 33 28 37 58 38 45 +48x41: 53 48 49 49 47 57 +40x47: 53 47 51 46 38 56 +48x49: 68 58 74 48 62 57 +47x47: 62 63 53 64 50 48 +47x37: 25 33 19 44 28 31 +50x37: 30 35 31 34 34 28 +47x37: 44 48 32 52 43 45 +49x40: 37 29 31 42 31 38 +39x42: 33 37 38 43 45 54 +39x38: 50 30 48 21 39 45 +46x50: 66 50 65 52 66 58 +43x37: 45 45 35 42 40 37 +44x37: 40 36 47 39 46 44 +48x49: 50 59 83 53 58 64 +44x45: 37 33 38 30 38 34 +45x39: 32 31 35 22 40 34 +36x48: 30 25 36 33 30 38 +48x38: 40 52 57 56 38 40 +46x36: 55 33 40 40 50 38 +50x36: 41 42 59 46 46 46 +41x50: 57 46 52 63 41 57 +35x48: 33 37 30 25 24 26 +42x36: 37 38 29 36 43 47 +42x44: 46 45 42 49 51 50 +38x38: 37 37 42 50 27 31 +44x37: 49 50 36 34 39 42 +35x38: 22 19 15 23 25 27 +40x38: 40 42 41 42 23 47 +43x37: 31 31 24 26 27 29 +45x43: 40 32 34 30 38 36 +49x36: 46 36 49 45 49 48 +43x35: 26 36 21 23 28 20 +38x37: 21 30 20 23 23 26 +46x35: 45 41 43 43 38 39 +45x43: 40 40 28 40 34 28 +42x49: 54 47 49 49 54 63 +35x47: 25 23 35 23 41 18 +38x44: 31 26 27 26 27 30 +41x43: 37 48 54 39 36 59 +46x42: 49 51 58 42 60 40 +39x39: 37 38 29 52 30 45 +43x49: 45 50 64 52 62 53 +38x37: 37 40 34 29 42 34 +50x39: 36 35 31 40 32 34 +42x36: 28 24 29 33 24 30 +39x47: 29 21 28 44 35 37 +50x49: 68 58 73 64 56 62 +42x39: 26 23 34 32 37 30 +47x37: 37 26 28 25 31 32 +44x45: 34 38 35 34 34 34 +40x40: 22 35 36 22 23 30 +42x36: 35 20 38 28 26 20 +46x38: 36 26 31 25 24 38 +39x37: 26 27 22 19 35 26 +47x38: 38 46 49 40 47 55 +39x41: 36 20 29 25 24 35 +43x39: 40 48 44 38 45 43 +50x49: 49 41 50 48 31 36 +44x41: 36 44 52 46 55 45 +35x45: 29 36 40 39 49 48 +38x35: 32 44 39 35 27 29 +50x42: 50 46 51 68 49 58 +48x44: 50 58 59 54 46 59 +44x36: 37 44 39 36 48 39 +48x46: 50 50 56 75 55 53 +38x35: 24 17 23 25 17 25 +36x49: 49 40 52 49 49 35 +48x36: 35 35 26 38 33 24 +44x46: 30 34 37 38 36 34 +46x41: 59 49 48 38 53 45 +42x45: 35 34 38 36 30 36 +42x47: 54 49 52 48 51 51 +40x40: 18 26 28 40 25 31 +39x43: 47 48 43 33 40 48 +48x35: 49 39 41 53 39 38 +47x45: 28 30 39 44 29 55 +41x35: 28 16 29 24 23 22 +46x45: 65 66 45 52 51 39 +37x39: 47 33 27 37 31 46 +43x44: 59 41 52 52 40 50 +49x47: 58 65 58 66 50 57 +41x48: 33 32 43 40 30 30 +50x38: 56 46 54 44 57 38 +45x39: 30 39 32 31 31 32 +44x41: 29 34 31 30 25 32 +44x49: 39 39 38 36 37 34 +42x44: 27 38 35 33 33 30 +46x47: 54 47 71 55 54 56 +49x40: 55 53 48 55 45 46 +39x39: 19 25 31 28 37 29 +40x38: 21 23 30 19 39 24 +45x45: 39 31 33 43 38 40 +49x46: 49 61 52 52 67 63 +45x45: 45 49 60 43 46 70 +43x38: 37 44 66 23 43 45 +49x48: 43 39 37 47 46 43 +46x49: 56 70 52 50 65 52 +45x37: 40 36 53 54 34 42 +43x50: 53 41 56 62 63 56 +50x45: 35 37 39 42 45 41 +49x37: 46 54 49 46 46 39 +41x46: 49 45 50 43 51 53 +45x35: 22 32 21 23 31 35 +47x44: 57 62 53 51 49 47 +39x45: 45 50 47 42 48 39 +42x36: 20 34 26 35 24 29 +49x41: 31 39 30 32 40 36 +41x41: 46 42 49 46 38 40 +42x45: 52 40 54 57 39 51 +37x39: 29 29 40 37 35 52 +40x35: 32 40 35 37 40 31 +42x48: 49 46 51 50 55 59 +40x48: 50 51 47 41 46 60 +45x46: 49 30 34 41 36 34 +38x39: 34 42 32 40 40 38 +46x35: 30 37 40 41 43 55 +45x42: 58 50 47 49 43 45 +48x35: 47 47 46 39 44 37 +49x42: 50 61 58 50 59 40 +49x37: 40 41 52 49 49 49 +48x47: 65 59 46 57 59 59 +35x35: 26 17 15 28 13 22 +42x49: 34 37 41 32 36 43 +44x43: 32 39 30 32 30 33 +43x47: 50 57 49 56 50 48 +43x46: 52 49 59 50 54 43 +44x41: 30 20 30 31 36 35 +49x50: 56 69 58 64 72 56 +43x44: 27 34 32 29 43 31 +43x50: 49 51 54 56 62 58 +49x37: 48 45 45 50 44 47 +46x36: 50 48 45 39 36 39 +46x50: 36 30 46 42 44 41 +42x46: 33 40 42 29 31 35 +50x36: 45 52 56 47 37 43 +43x36: 28 30 26 29 27 27 +36x47: 44 34 48 49 44 43 +42x47: 38 22 37 32 35 46 From 393f80f314c5b99afc3c567314b8df96d3d963bd Mon Sep 17 00:00:00 2001 From: ktkk Date: Fri, 12 Dec 2025 14:48:57 +0000 Subject: [PATCH 13/17] WIP: implement part 1 --- src/days/day12.zig | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/days/day12.zig b/src/days/day12.zig index d940d18..17f6c7e 100644 --- a/src/days/day12.zig +++ b/src/days/day12.zig @@ -169,5 +169,50 @@ const Region = struct { } } } + + pub fn createEmpty(self: Self, allocator: std.mem.Allocator) !EmptyRegion { + return try .init(allocator, self.width, self.height); + } +}; + +const EmptyRegion = struct { + grid: [][]bool, + filled_spaces: usize, + + allocator: std.mem.Allocator, + + const Self = @This(); + + pub fn init(allocator: std.mem.Allocator, width: u8, height: u8) !Self { + const h = try allocator.alloc([]bool, height); + for (0..height) |i| { + const w = try allocator.alloc(u8, width); + @memset(w, false); + h[i] = w; + } + return .{ + .grid = h, + .filled_spaces = 0, + .allocator = allocator, + }; + } + + pub fn deinit(self: Self) void { + for (self.grid) |row| { + self.allocator.free(row); + } + self.allocator.free(self.grid); + } + + pub fn fits(self: Self, present: Present) bool { + std.debug.assert(self.grid.len > 0); + const size = self.grid.len * self.grid[0].len; + if ((size - self.filled_spaces) < present.shape.count()) { + return false; + } + + // TODO: Implementation + return false; + } }; From bc89b177a26f4f99825629c83fb20b8b80a947a7 Mon Sep 17 00:00:00 2001 From: ktkk Date: Fri, 12 Dec 2025 14:55:11 +0000 Subject: [PATCH 14/17] Add README --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4e39aa0 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +# Advent of Code 2025 + +| Day | Part 1 | Part 2 | +| --- | ------ | ------ | +| 1 | [x] | [x] | +| 2 | [x] | [x] | +| 3 | [x] | [x] | +| 4 | [x] | [x] | +| 5 | [x] | [x] | +| 6 | [x] | [x] | +| 7 | [x] | [x] | +| 8 | [ ] | [ ] | +| 9 | [x] | [x] | +| 10 | [x] | [ ] | +| 11 | [x] | [x] | +| 12 | [ ] | [ ] | From f088a5a21a5da063947e66089213ba0aa220d8ff Mon Sep 17 00:00:00 2001 From: ktkk Date: Fri, 12 Dec 2025 16:35:12 +0000 Subject: [PATCH 15/17] WIP: implement part 1 --- src/days/day12.zig | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/days/day12.zig b/src/days/day12.zig index 17f6c7e..26d586b 100644 --- a/src/days/day12.zig +++ b/src/days/day12.zig @@ -111,13 +111,26 @@ pub fn run(allocator: std.mem.Allocator) !void { } } - for (presents.items, 0..) |present, i| { - std.debug.print("{d}:\n{f}\n\n", .{i, present}); - } + var accumulator: usize = 0; for (regions.items) |region| { - std.debug.print("{f}\n", .{region}); + var area_needed: usize = 0; + for (region.required_presents, 0..) |amount, i| { + area_needed += amount * presents.items[i].area(); + } + if (area_needed < region.area()) { + std.debug.print("{f}\nfits\n", .{region}); + accumulator += 1; + } } + + var buffer: [8]u8 = undefined; + var stdout_writer = std.fs.File.stdout().writer(&buffer); + const stdout = &stdout_writer.interface; + + try stdout.print("{d}\n", .{accumulator}); + + try stdout.flush(); } const Present = struct { @@ -147,6 +160,10 @@ const Present = struct { const index = (y * Width) + x; return self.shape.isSet(index); } + + pub fn area(self: Self) usize { + return self.shape.count(); + } }; const Region = struct { @@ -173,6 +190,10 @@ const Region = struct { pub fn createEmpty(self: Self, allocator: std.mem.Allocator) !EmptyRegion { return try .init(allocator, self.width, self.height); } + + pub fn area(self: Self) usize { + return self.width * self.height; + } }; const EmptyRegion = struct { From 0633ee80a9450b8a6c6cd2c93b122cef7b2a5f86 Mon Sep 17 00:00:00 2001 From: ktkk Date: Fri, 12 Dec 2025 22:07:05 +0000 Subject: [PATCH 16/17] Finish day12, part 1 This feels like cheating --- src/days/day12.zig | 81 +++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 40 deletions(-) diff --git a/src/days/day12.zig b/src/days/day12.zig index 26d586b..354fe56 100644 --- a/src/days/day12.zig +++ b/src/days/day12.zig @@ -3,42 +3,42 @@ const std = @import("std"); pub const title = "Day 12: Christmas Tree Farm"; pub fn run(allocator: std.mem.Allocator) !void { - //const input = @embedFile("./input/day12.txt"); - const input = - \\0: - \\### - \\##. - \\##. - \\ - \\1: - \\### - \\##. - \\.## - \\ - \\2: - \\.## - \\### - \\##. - \\ - \\3: - \\##. - \\### - \\##. - \\ - \\4: - \\### - \\#.. - \\### - \\ - \\5: - \\### - \\.#. - \\### - \\ - \\4x4: 0 0 0 0 2 0 - \\12x5: 1 0 1 0 2 2 - \\12x5: 1 0 1 0 3 2 - ; + const input = @embedFile("./input/day12.txt"); + //const input = + // \\0: + // \\### + // \\##. + // \\##. + // \\ + // \\1: + // \\### + // \\##. + // \\.## + // \\ + // \\2: + // \\.## + // \\### + // \\##. + // \\ + // \\3: + // \\##. + // \\### + // \\##. + // \\ + // \\4: + // \\### + // \\#.. + // \\### + // \\ + // \\5: + // \\### + // \\.#. + // \\### + // \\ + // \\4x4: 0 0 0 0 2 0 + // \\12x5: 1 0 1 0 2 2 + // \\12x5: 1 0 1 0 3 2 + // ; var lines = std.mem.tokenizeScalar(u8, input, '\n'); @@ -69,8 +69,8 @@ pub fn run(allocator: std.mem.Allocator) !void { if (semicolon_pos != 0) { if (x_pos) |p| { // region - const width = try std.fmt.parseUnsigned(u8, line[0..p], 10); - const height = try std.fmt.parseUnsigned(u8, line[p + 1..semicolon_pos], 10); + const width = try std.fmt.parseUnsigned(usize, line[0..p], 10); + const height = try std.fmt.parseUnsigned(usize, line[p + 1..semicolon_pos], 10); var required_presents: std.ArrayList(u8) = .empty; defer required_presents.deinit(allocator); @@ -114,6 +114,7 @@ pub fn run(allocator: std.mem.Allocator) !void { var accumulator: usize = 0; for (regions.items) |region| { + std.debug.print("{f}\n", .{region}); var area_needed: usize = 0; for (region.required_presents, 0..) |amount, i| { area_needed += amount * presents.items[i].area(); @@ -167,8 +168,8 @@ const Present = struct { }; const Region = struct { - width: u8, - height: u8, + width: usize, + height: usize, required_presents: []u8, const Self = @This(); From b3f8ab19ffc911be4be485de0af2ace55a7ab7bc Mon Sep 17 00:00:00 2001 From: ktkk Date: Fri, 12 Dec 2025 22:08:19 +0000 Subject: [PATCH 17/17] Add hyperfine to nix env --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index e668d05..6649f39 100644 --- a/flake.nix +++ b/flake.nix @@ -17,6 +17,7 @@ nativeBuildInputs = with pkgs; [ zig zls + hyperfine ]; buildInputs = with pkgs; [];