r/excel • u/Downtown-Economics26 647 • Dec 04 '25
Discussion Advent of Code 2025 Day 4
It's back. Only 12 days of puzzles this year.
Today's puzzle "Printing Department" link below.
https://adventofcode.com/2025/day/4
Three requests on posting answers:
Please try blacking out / marking as spoiler with at least your formula solutions so people don't get hints at how to solve the problems unless they want to see them.
The creator of Advent of Code requests you DO NOT share your puzzle input publicly to prevent others from cloning the site where a lot of work goes into producing these challenges.
There is no requirement on how you figure out your solution (many will be trying to do it in one formula, possibly including me) besides please do not share any ChatGPT/AI generated answers as this is a challenge for humans.
1
u/Downtown-Economics26 647 Dec 04 '25 edited Dec 04 '25
For Part 1 I went mostly old school excel and split out the input into a grid then just did the old and reliable relative reference to get a count and summed:
=IFERROR(IF(Input!B3="@",--(COUNTIFS(Input!A2:C4,"@")<5),"."),0)Part 2 -- just don't have the patience to figure out all your guys' clever formula iteration methods, although I'm duly impressed looking at them, VBA answer below.
2
u/SheepiCagio 1 Dec 04 '25
Input in A1:A139
P1:
=LET(
map;TOCOL(DROP(REDUCE(0;A1:A139;LAMBDA(a;v;VSTACK(a;MID(v;SEQUENCE(LEN(v));1))));1));
addr;FILTER(TOCOL(SEQUENCE(LEN(A1);;10000;10000)+SEQUENCE(;LEN(A1)));map="@");
remainingaddr;FILTER(addr;MAP(addr;LAMBDA(a;--(SUM(--(ISNUMBER(
XMATCH(a+{10000;-10000;1;-1;10001;-10001;-9999;9999};addr;0))))>=4))));
rows(addr)-rows(remainingaddr))
P2:
=LET(
map;TOCOL(DROP(REDUCE(0;A1:A139;LAMBDA(a;v;VSTACK(a;MID(v;SEQUENCE(LEN(v));1))));1));
addr;FILTER(TOCOL(SEQUENCE(LEN(A1);;10000;10000)+SEQUENCE(;LEN(A1)));map="@");
remainingaddr;REDUCE(addr;SEQUENCE(55);LAMBDA(acc;v;
FILTER(acc;MAP(acc;LAMBDA(a;--(SUM(--(ISNUMBER(
XMATCH(a+{10000;-10000;1;-1;10001;-10001;-9999;9999};acc;0))))>=4))))));
ROWS(addr)-ROWS(remaining))
2
u/Anonymous1378 1542 Dec 04 '25 edited Dec 04 '25
Part 1
=LET(data,A13:A151,size,MAX(LEN(data)),
buffer,MID(VSTACK(REPT(".",size+2),"."&data&".",REPT(".",size+2)),SEQUENCE(,size+2),1),
check,MAKEARRAY(ROWS(data),size,LAMBDA(r,c,IF(INDEX(buffer,r+1,c+1)="@",SUM(--((INDEX(buffer,r+1+{-1,-1,-1;0,0,0;1,1,1},c+1+{-1,0,1;-1,0,1;-1,0,1}))="@")),""))),
SUM(--(check<=4)))
Part 2 (where I had to throw my Part 1 approach in the trash as MAKEARRAY(INDEX()) wasn't optimized enough for excel for the web)
=LET(data,A13:A151,size,MAX(LEN(data)),grid,{1,1,1,1;1,1,1,-1;1,-1,1,-1;1,-1,-1,-1;-1,1,1,1;-1,1,-1,1;-1,-1,-1,1;-1,-1,-1,-1},
matrix,SUBSTITUTE(SUBSTITUTE(data,"@","1"),".","0"),
loop,LAMBDA(a,b,c,LET(
buffer,--MID(VSTACK(REPT(0,size+2),0&b&0,REPT(0,size+2)),SEQUENCE(,size+2),1),
check,REDUCE(0,SEQUENCE(8),LAMBDA(x,y,x+DROP(DROP(buffer,INDEX(grid,y,1),INDEX(grid,y,2)),INDEX(grid,y,3),INDEX(grid,y,4)))),
IF(c=0,b,a(a,BYROW(IF(check<4,0,DROP(DROP(buffer,1,1),-1,-1)),CONCAT),SUM(--(DROP(DROP(buffer,1,1),-1,-1)*(check<4))))))),
result,loop(loop,matrix,1),
SUM(--(MID(result,SEQUENCE(,size),1)<>MID(matrix,SEQUENCE(,size),1))))
2
u/RackofLambda 12 Dec 04 '25
Part 1:
C2:
=MID(A:.A,SEQUENCE(,MAX(LEN(A:.A))),1)N2:
=SUM(--MAP(C2#,OFFSET(C2#,-1,-1),OFFSET(C2#,1,1),LAMBDA(v,a,b,IF(v="@",SUM(N(a:b="@"))<5))))Part 2:
=LET(fn, LAMBDA(me,arr,[acc], LET(h, ROWS(arr)+1,w, COLUMNS(arr)+1,i, EXPAND("",h+1,,""),j, EXPAND("",,w,""),a, HSTACK(i,VSTACK(j,EXPAND(arr,h,w,""))),v, MAP({0;2;1;1;-2;2;-2;2},{1;1;0;2;-2;-2;2;2},{-2;0;-1;-1;0;0;0;0},{-1;-1;-2;0;0;0;0;0},LAMBDA(_r1,_c1,_r2,_c2, LET(x, DROP(DROP(a,_r1,_c1),_r2,_c2)="@", LAMBDA(x)))),b, IF(arr="@",REDUCE((@v)(),DROP(v,1),LAMBDA(acc,cur,acc+cur()))<4),c, SUM(--b),IF(c,me(me,IF(b,"",arr),acc+c),acc) )),fn(fn,MID(A:.A,SEQUENCE(,MAX(LEN(A:.A))),1)))1
u/Decronym Dec 04 '25 edited Dec 05 '25
Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:
Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.
Beep-boop, I am a helper bot. Please do not verify me as a solution.
31 acronyms in this thread; the most compressed thread commented on today has 24 acronyms.
[Thread #46473 for this sub, first seen 4th Dec 2025, 13:27] [FAQ] [Full list] ^[Contact] [Source code]