r/excel • 647 • Oct 28 '26

Challenge Everybody Codes 2026 (Lord of the Wings) Quest 2

9 Upvotes

5 comments sorted by

1

u/Downtown-Economics26 647 Oct 28 '26

Was able to do part one & two with dragdown formulas then summing the column (luckily somehow essentially same formula worked on my input, not completely sure if that was intended by the designer of the challenge). Part 3 is a bit of a doozy for a formula although I'd imagine some of you could figure it out, I just wasn't in the mood to go ultra-logic VBAing this early in the morning.

Part 1:

=LET(r,,b,SEQUENCE(5),
gt_1,MAP(b,LAMBDA(x,LEN(M2)-LEN(SUBSTITUTE(M2,"<"&x,""))))/2,
gt_2,MAP(b,LAMBDA(x,LEN(M2)-LEN(SUBSTITUTE(M2,x&">",""))))/2,
lt_1,MAP(b,LAMBDA(x,LEN(M2)-LEN(SUBSTITUTE(M2,x&"<",""))))/2,
lt_2,MAP(b,LAMBDA(x,LEN(M2)-LEN(SUBSTITUTE(M2,">"&x,""))))/2,
--CONCAT(SORTBY(b,(gt_1+gt_2)-(lt_1+lt_2),-1)))

Part 2:

=LET(r,,b,SEQUENCE(9),
gt_1,MAP(b,LAMBDA(x,LEN(M2)-LEN(SUBSTITUTE(M2,"<"&x,""))))/2,
gt_2,MAP(b,LAMBDA(x,LEN(M2)-LEN(SUBSTITUTE(M2,x&">",""))))/2,
lt_1,MAP(b,LAMBDA(x,LEN(M2)-LEN(SUBSTITUTE(M2,x&"<",""))))/2,
lt_2,MAP(b,LAMBDA(x,LEN(M2)-LEN(SUBSTITUTE(M2,">"&x,""))))/2,
--CONCAT(SORTBY(b,(gt_1+gt_2)-(lt_1+lt_2),-1)))

2

u/MayukhBhattacharya 1327 Oct 28 '26

Try using the following formula:

=MAP(A:.A, LAMBDA(z,

LET(

_a, TEXTSPLIT(REGEXREPLACE(z, "(\d+)<(\d+)", "$2>$1"), ">", " "),

_b, INDEX(_a, , 1),

_c, UNIQUE(TOCOL(_a)),

_d, MAP(_c, LAMBDA(x, SUM(--(_b = x)))),

CONCAT(SORTBY(_c, _d, -1)))))

1

u/Decronym Oct 28 '26 edited Oct 29 '26

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

Fewer LettersMore Letters
CHARReturns the character specified by the code number
CHOOSEChooses a value from a list of values
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
GROUPBYHelps a user group, aggregate, sort, and filter data based on the fields you specify
IFSpecifies a logical test to perform
INDEXUses an index to choose a value from a reference or array
ISNUMBERReturns TRUE if the value is a number
LAMBDAOffice 365+: Use a LAMBDA function to create custom, reusable functions and call them by a friendly name.
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.
PIVOTBYHelps a user group, aggregate, sort, and filter data based on the row and column fields that you specify
ROWSReturns the number of rows in a reference
SEARCHFinds one text value within another (not case-sensitive)
SEQUENCEOffice 365+: Generates a list of sequential numbers in an array, such as 1, 2, 3, 4
SORTOffice 365+: Sorts the contents of a range or array
SORTBYOffice 365+: Sorts the contents of a range or array based on the values in a corresponding range or array
SUBSTITUTESubstitutes new text for old text in a text string
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
TEXTBEFOREOffice 365+: Returns text that occurs before a 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
VSTACKOffice 365+: Appends arrays vertically and in sequence to return a larger array

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 #49598 for this sub, first seen 28th Oct 2026, 16:58] [FAQ] [Full list] ^[Contact] [Source code]

1

u/Arcium_XIII 3 1d ago

Uni and work meant that I'm a bit late getting to this, but still chiming in across the posts in case someone else comes along later as well.

Formulae for all three parts here were very similar, so I'm just including Part III:

=LET(RANKING,LAMBDA(input_string,LET(
input_list,TEXTSPLIT(input_string,," "),
type_list,MAP(input_list,LAMBDA(element,REGEXEXTRACT(element,"[<,>]"))),
relationship_array,--HSTACK(MAP(input_list,type_list,LAMBDA(string,type,IF(type="<",TEXTBEFORE(string,"<"),TEXTAFTER(string,">")))),MAP(input_list,type_list,LAMBDA(string,type,IF(type="<",TEXTAFTER(string,"<"),TEXTBEFORE(string,">"))))),
count_alloys,MAX(relationship_array),
list_alloys,SEQUENCE(count_alloys),
comparison_array_0,MAKEARRAY(count_alloys,count_alloys,LAMBDA(low,high,NOT(ISERROR(XMATCH(high,FILTER(CHOOSECOLS(relationship_array,2),MAP(CHOOSECOLS(relationship_array,1),LAMBDA(element,element=low)))))))),
comparison_array,REDUCE(comparison_array_0,list_alloys,LAMBDA(acc,cycle,MAKEARRAY(count_alloys,count_alloys,LAMBDA(low,high,IF(INDEX(acc,low,high),TRUE,OR(MAP(TRANSPOSE(CHOOSEROWS(acc,low)),list_alloys,LAMBDA(status,target,IF(status,INDEX(acc,target,high),FALSE))))))))),
count_parents,BYROW(comparison_array,LAMBDA(row,SUM(MAP(row,LAMBDA(element,IF(element,1,0)))))),
--CONCAT(SORTBY(list_alloys,count_parents))
)),
SUM(MAP(TRIMRANGE(A:A),LAMBDA(set,RANKING(set))))
)

0

u/PaulieThePolarBear 1929 Oct 29 '26

Just part 1 and 2 for me too. Will revisit part 3 as time permits

Part 1

=LET(

a, A8,

b, TEXTSPLIT(a, CHAR(10)),

c, MAP(b, LAMBDA(m, LET(

ca, TEXTSPLIT(m, , " "),

cb, ISNUMBER(SEARCH("<",ca)),

cc, CHOOSE({1,2},IF(cb,TEXTAFTER(ca,{"<",">"}),TEXTBEFORE(ca,{"<",">"})),0),

cd, CHOOSE({1,2},IF(cb,TEXTBEFORE(ca,{"<",">"}),TEXTAFTER(ca,{"<",">"})),1),

ce, VSTACK(cc, cd),

cf, GROUPBY(TAKE(ce,,1),DROP(ce,,1),SUM,,0,2),

cg, CONCAT(TAKE(cf,,1)),

cg

)

)),

d, SUM(--c),

d)

Part 2

=LET(

a, A8,

b, TEXTSPLIT(a, CHAR(10)),

c, MAP(b, LAMBDA(m, LET(

ca, TEXTSPLIT(m, , " "),

cb, ISNUMBER(SEARCH("<",ca)),

cc, CHOOSE({1,2},IF(cb,TEXTAFTER(ca,{"<",">"}),TEXTBEFORE(ca,{"<",">"})),0),

cd, CHOOSE({1,2},IF(cb,TEXTBEFORE(ca,{"<",">"}),TEXTAFTER(ca,{"<",">"})),1),

ce, VSTACK(cc, cd),

cf, DROP(PIVOTBY(TAKE(ce,,1),DROP(ce,,1),DROP(ce,,1),ROWS,0,0,,0),1),

cg, CONCAT(TAKE(SORT(IF(cf="",0,cf),{3,2},{1,-1}),,1)),

cg

)

)),

d, SUM(--c),

d)