r/excel • 647 • Dec 03 '25

Discussion Advent of Code 2025 Day 3

It's back. Only 12 days of puzzles this year.

Today's puzzle "Lobby" link below.

https://adventofcode.com/2025/day/3

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.

13 Upvotes

19 comments sorted by

3

u/Anonymous1378 1542 Dec 03 '25 edited Dec 04 '25

Part 1

=LET(data,K31:K230,
split,LAMBDA(w,x,--MID(x,SEQUENCE(,MAX(LEN(x))+w),1)),
first,BYROW(split(-1,data),MAX),
second,BYROW(IFERROR(split(0,MAP(data,first,LAMBDA(y,z,TEXTAFTER(y,z)))),0),MAX),
SUM(--(first&second)))

Part 2

=LET(data,K31:K230,
split,LAMBDA(w,x,--MID(LEFT(x,LEN(x)+w),SEQUENCE(,MAX(LEN(x))),1)),
first,BYROW(IFERROR(--split(-11,data),0),MAX),
loop,LAMBDA(s,t,u,v,LET(p,MAP(u,v,LAMBDA(q,r,TEXTAFTER(q,RIGHT(r)))),IF(t=1,v,s(s,t+1,p,v&BYROW(IFERROR(--split(t,p),0),MAX))))),
SUM(--loop(loop,-10,data,first)))

Slight refinement to Part 2:

=LET(data,K31:K230,
split,LAMBDA(w,x,--MID(LEFT(x,LEN(x)-w+1),SEQUENCE(,MAX(LEN(x))),1)),
loop,LAMBDA(s,t,u,v,LET(p,MAP(u,v,LAMBDA(q,r,TEXTAFTER(q,IFERROR(RIGHT(r),"")))),IF(t=0,v,s(s,t-1,p,v&BYROW(IFERROR(--split(t,p),0),MAX))))),
SUM(--loop(loop,12,data,IF(ROW(data),""))))

1

u/Downtown-Economics26 647 Dec 03 '25

I will need to study this to resolve my looping issues with formulas. I understand conceptually what's going on in your part 2 solution but not the full functionality.

2

u/Way2trivial 475 Dec 03 '25 edited Dec 03 '25

any answer works right? so long as you get it? even with 11 helper columns?

my b3 =VALUE(MAX(VALUE(UNIQUE(MID(A3,SEQUENCE(,LEN(A3)-(B$2)),1),TRUE))))
my c3 =TEXTAFTER(A3,B3)

b2 started at 11 down to x2 which had zero

then copied it over 11 times...

2

u/Downtown-Economics26 647 Dec 03 '25

Yup. All solutions are equal when you put them in the answer box.

1

u/Downtown-Economics26 647 Dec 03 '25

Was able to do part 1 with a drag-down formula, will have to revisit Part 2 later to see if I can figure out a non-ridiculous formula solution, the part 2 solution looks relatively trivial to do in VBA.

=LET(a_1,--MID(A1,SEQUENCE(LEN(A1)),1),

a_2,MAX(DROP(a_1,-1)),

pos,XMATCH(a_2,a_1,0),

a_3,MAX(TAKE(a_1,-(LEN(A1)-pos))),

--(a_2&a_3))

Then take sum of the column.

1

u/Downtown-Economics26 647 Dec 03 '25

Part 2 VBA Answer:

Sub AOC2025D03P02()

Dim ans As LongLong

rcount = Application.CountA(Range("a:a"))
rlen = Len(Range("a1"))
lim = 12
ans = 0

For r = 1 To rcount
alen = 0
cp = 1
lv = ""
rs = Range("a" & r)
    For d = 1 To lim
    maxp = rlen - lim + 1 + alen
    maxv = -1
    pmax = 0
        For p = cp To maxp
        tv = Mid(rs, p, 1)
        If tv > maxv Then
        maxv = tv
        pmax = p
        End If
        Next p
    cp = pmax + 1
    alen = alen + 1
    lv = lv & maxv
    Next d
ans = ans + lv
Next r

Debug.Print ans

End Sub

1

u/khosrua 16 Dec 03 '25

Part 2 seems trivial if done in python if you can do recursion or just update variables for each loop, which Excel has neither, unless I learn something new again today.

2

u/Downtown-Economics26 647 Dec 03 '25

You can do recursion via LAMBDA... check some of the other solutions here they're pretty impressive in their loopiness.

2

u/khosrua 16 Dec 04 '25

I got it.

=LET(

input,A8,

length,$B$3,

inputRng, --MID( input,SEQUENCE(LEN(input)),1),

seq, SEQUENCE(length,,length-1,-1),

idx, SCAN(0,seq,LAMBDA(a,n,LET(

rng, DROP(DROP(inputRng,-n),a),

mx, MAX(rng),

XMATCH(mx,rng,0)+a)

)),

--CONCAT(INDEX(inputRng,idx)))

So it worked out SCAN can be used to carry over the index of the previous selection to block out for the next selection, but it turned out i could just use the index to retrieve the digit so here we go

2

u/SheepiCagio 1 Dec 04 '25

And this even isn't true recursion, which can be accomplished in Excel as well....

1

u/khosrua 16 Dec 04 '25

yeah, a for loop with a couple of carryover variables are enough.

i havent got luck with recursive lambda so far so happy with the solution

3

u/PaulieThePolarBear 1927 Dec 03 '25

Part 1

=SUM(MAP(A1:A200,LAMBDA(m,LET(
a, SEQUENCE(LEN(m)),
b, --MID(m, a, 1),
c, MAX(DROP(b,-1)),
d, XMATCH(c, b),
e, MAX(FILTER(b, a>d)),
f, c*10+e,
f
))))

Part 2 to follow later in my day

2

u/khosrua 16 Dec 03 '25

I just used DROP again for e

Resisting urge to use python for part 2

2

u/SheepiCagio 1 Dec 03 '25

I found today rather simple compared to the first two days. This provides the answers for part 1 and 2 simultaneously.

=MAP({2,12};LAMBDA(y;

SUM(BYROW(TEXTSPLIT(B1;;CHAR(10));LAMBDA(x;LET(

nrs;--MID(x;SEQUENCE(100);1);

--CONCAT(ROUNDDOWN(SCAN(0;SEQUENCE(y;;y;-1);LAMBDA(a;v;LET(

s;(a-ROUNDDOWN(a;0))*100;

rng;INDEX(nrs;SEQUENCE(101-s-v;;s+1));

loc;XMATCH(MAX(rng);rng)+s;

MAX(rng)+MIN(0.999;loc/100))));0))))))))

2

u/Murky-Pin-8541 Dec 03 '25

wild how fast these puzzles come and go, makes you appreciate the challenge more

2

u/RackofLambda 12 Dec 03 '25

=SUM(MAP(A:.A,LAMBDA(x,MAXJOLT(--MID(x,SEQUENCE(LEN(x)),1),12))))

Where:

MAXJOLT = LAMBDA(vec,num,[rws],[acc],LET(rem,num-LEN(acc),IF(rem=1,VALUE(acc&MAX(vec)),LET(val,MAX(DROP(vec,rws)),pos,XMATCH(val,vec),IF(ROWS(vec)-pos+1<rem,MAXJOLT(vec,num,rws-1,acc),MAXJOLT(DROP(vec,pos),num,,acc&val))))))

Works for Part 1 and 2 (set the num variable accordingly).

2

u/finickyone 1770 Dec 06 '25

Bit bashy

>! =LET(v,A3,l,LEN(v),s,SEQUENCE(\l2)-1,i,INT(s/l)+1,m,MOD(s,l)+1,MAX(TOCOL(IF(m>i,MID(v,i,1)&MID(v,m,1),1/0),2)+0))

!<

1

u/Decronym Dec 03 '25 edited Dec 06 '25

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:

Fewer LettersMore Letters
BYROWOffice 365+: Applies a LAMBDA to each row and returns an array of the results. For example, if the original array is 3 columns by 2 rows, the returned array is 1 column by 2 rows.
CHARReturns the character specified by the code number
CONCAT2019+: Combines the text from multiple ranges and/or strings, but it doesn't provide the delimiter or IgnoreEmpty arguments.
DROPOffice 365+: Excludes a specified number of rows or columns from the start or end of an array
FILTEROffice 365+: Filters a range of data based on criteria you define
IFSpecifies a logical test to perform
IFERRORReturns a value you specify if a formula evaluates to an error; otherwise, returns the result of the formula
INDEXUses an index to choose a value from a reference or array
INTRounds a number down to the nearest integer
LAMBDAOffice 365+: Use a LAMBDA function to create custom, reusable functions and call them by a friendly name.
LEFTReturns the leftmost characters from a text value
LENReturns the number of characters in a text string
LETOffice 365+: Assigns names to calculation results to allow storing intermediate calculations, values, or defining names inside a formula
MAPOffice 365+: Returns an array formed by mapping each value in the array(s) to a new value by applying a LAMBDA to create a new value.
MAXReturns the maximum value in a list of arguments
MIDReturns a specific number of characters from a text string starting at the position you specify
MINReturns the minimum value in a list of arguments
MODReturns the remainder from division
RIGHTReturns the rightmost characters from a text value
ROUNDDOWNRounds a number down, toward zero
ROWSReturns the number of rows in a reference
SCANOffice 365+: Scans an array by applying a LAMBDA to each value and returns an array that has each intermediate value.
SEQUENCEOffice 365+: Generates a list of sequential numbers in an array, such as 1, 2, 3, 4
SUMAdds its arguments
TAKEOffice 365+: Returns a specified number of contiguous rows or columns from the start or end of an array
TEXTAFTEROffice 365+: Returns text that occurs after given character or string
TEXTSPLITOffice 365+: Splits text strings by using column and row delimiters
TOCOLOffice 365+: Returns the array in a single column
UNIQUEOffice 365+: Returns a list of unique values in a list or range
VALUEConverts a text argument to a number
XMATCHOffice 365+: Returns the relative position of an item in an array or range of cells.

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 38 acronyms.
[Thread #46457 for this sub, first seen 3rd Dec 2025, 12:27] [FAQ] [Full list] ^[Contact] [Source code]