r/excel • u/Downtown-Economics26 647 • Dec 01 '25
Discussion Advent of Code 2025 Day 1
It's back. Only 12 days of puzzles this year.
Today's puzzle "Secret Entrance" link below.
https://adventofcode.com/2025/day/1
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.
3
u/Downtown-Economics26 647 Dec 01 '25 edited Dec 01 '25
Part 1:
Part 2:
For part 2, I couldn't quite figure out how to do in one formula easily. So I used part 1 solution and made it give the position for each move in column C and then put number of turns in column D. In column E in cell D2 i put this value and dragged down, it has a ref error for first row. This gave me number of 0s per instruction which I then summed.
Edit: posted the wrong function orginally with the #REF from a relative reference in the first.
Edit 2: Fixed Part 1 solution I actually used instead of the modified part 2 version of it.
2
u/Perohmtoir 51 Dec 01 '25 edited Dec 01 '25
Part 1:
Part 2. Doing it into a single formula required an inelegant trickery.
Part 2 without the single formula constraint (less time spent on trickery), using columns B and C:
B1:
C2, extended down, summed.
5
u/TooCupcake Dec 01 '25
This is a lot of fun, I feel like an accomplished Excel user now lol.
Thank you for sharing, I’ll be following along.
4
u/Anonymous1378 1542 Dec 02 '25 edited Dec 03 '25
Part one:
=SUM(--(SCAN(50,--SUBSTITUTE(SUBSTITUTE(A31:A4134,"R",""),"L","-"),LAMBDA(x,y,MOD(x+y,100)))=0))
Part two
=LET(_a,SCAN(50,--SUBSTITUTE(SUBSTITUTE(A31:A4134,"R",""),"L","-"),LAMBDA(x,y,x+y)), REDUCE(0,SEQUENCE(ROWS(_a)-1)+1,LAMBDA(v,w,v+ABS((FLOOR.MATH(INDEX(_a,w),100)-FLOOR.MATH(INDEX(_a,w-1),100))/100))))
Hindsight EDIT - REDUCE is not needed here:
=LET(_a,SCAN(50,--SUBSTITUTE(SUBSTITUTE(A31:A4134,"R",""),"L","-"),LAMBDA(x,y,x+y)),
SUM(ABS((FLOOR.MATH(DROP(_a,1),100)-FLOOR.MATH(DROP(_a,-1),100))/100)))
Part two did get me the answer required, but I'm not entirely sure how robust it is. I have a sneaking suspicion that it doesn't cover some edge cases, but perhaps I got lucky.
3
u/Lalo_ATX Dec 01 '25 edited Dec 01 '25
I don't like cramming all the logic into a single cell, so I did it with stepwise array columns. You could put each of these steps into a single LET() statement, I just don't prefer that.
Assume your input is in column A. All the formulas are in columns B through G. Columns B through F are just setup, the magic is in column G.
B1: =MAP(A:.A,LAMBDA(x,IF(LEFT(x,1)="L",-1,1)))
C1: =MAP(A:.A,LAMBDA(x,RIGHT(x,LEN(x)-1)+0))
D1: =B1#*C1#
E1: =VSTACK({50},DROP(F1#,-1))
F1: =SCAN(50,D1#,LAMBDA(a,b,a+b))
G1: =LET(_bq,MAP(B1#*E1#,LAMBDA(x,FLOOR.MATH(x/100))),_aq,MAP(B1#*F1#,LAMBDA(x,FLOOR.MATH(x/100))),ABS(_aq-_bq))
and the answer is the sum of column G
=SUM(G1#)My friend figured out the elegant math in column G, I'm genuinely impressed by it, it naturally avoids double-counting when a turn begins on a zero, without an IF.
2
u/PaulieThePolarBear 1927 Dec 01 '25
Part 1
=LET(
a,A1:A4503,
b, SCAN(50, a, LAMBDA(x,y, MOD(x+IF(LEFT(y)="R",1,-1)*REPLACE(y, 1, 1,),100))),
c, SUM(--(b=0)),
c)
Part 2 to follow later in my day
2
u/Altruistic-Worry-919 Dec 01 '25
skills hitting different now lol keep at it
2
u/PaulieThePolarBear 1927 Dec 02 '25
Part 1 here
Part 2
=LET(a, A1:A4503,b, 50,c, LEFT(a),d, --REPLACE(a, 1, 1,),e, SCAN(b, SEQUENCE(ROWS(a)), LAMBDA(x,y, MOD(x+IF(INDEX(c,y)="R",1,-1)*INDEX(d, y),100))),f, VSTACK(b, DROP(e,-1)),g, QUOTIENT(d, 100) + (f<>0)*IF(c="R", e<f, (e>f)+(e=0)),h, SUM(g),h)1
u/Decronym Dec 01 '25 edited Dec 03 '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.
[Thread #46425 for this sub, first seen 1st Dec 2025, 18:03] [FAQ] [Full list] ^[Contact] [Source code]
1
u/SheepiCagio 1 Dec 03 '25
P1:
=SUM(--(SCAN(50;A13:A4420;LAMBDA(a;v;LET(x;IF(LEFT(v)="L";-1;1);MOD(a+--MID(v;2;10)*x;100))))=0))
P2:
=SUM(LET(in;A13:A4420;
pos;SCAN(50;in;LAMBDA(a;v;LET(x;IF(LEFT(v)="L";-1;1);MOD(a+--MID(v;2;10)*x;100))));
chng;MID(in;2;10)*IF(LEFT(in)="R";1;-1);prev;MOD(pos+chng*-1;100);
MAP(prev;chng;INT(ABS(chng)/100);LAMBDA(a;b;d;
d+IF(a=0;0;
IF(OR(ROUND(a+(b/100-INT(ABS(b/100))*SIGN(b))*100;0)>=100;
ROUND(a+(b/100-INT(ABS(b/100))*SIGN(b))*100;0)<=0);1;0))))))
1
u/RackofLambda 12 Dec 03 '25
Part 1:
=SUM(N(NOT(SCAN(50,-SUBSTITUTE(SUBSTITUTE(A:.A,"R","-"),"L",),LAMBDA(a,v,MOD(SUM(a,v),100))))))Part 2:
=LET(VALS,LAMBDA(a,[b],LAMBDA(x,CHOOSE(x,a,b))),REDUCE(VALS(50),-SUBSTITUTE(SUBSTITUTE(A:.A,"R","-"),"L",),LAMBDA(a,v,LET(i,MOD(a(1)+SEQUENCE(ABS(v))*SIGN(v),100),VALS(TAKE(i,-1),SUM(a(2),N(NOT(i)))))))(2))0
u/Party-Sherbet-2063 Dec 01 '25
is the best for feeling smart without trying too hard