— CAN YOU SOLVE THIS - EXCEL CHALLENGE 182 —
(Solutions in any language are also welcome for Excel Challenges)
Find the missing numbers in Arithmetic Progressions given.
An arithmetic progression or arithmetic sequence (AP) is a sequence of numbers such that the difference from any succeeding term to its preceding term remains constant throughout the sequence. The constant difference is called common difference of that arithmetic progression.
Ex - 5, 12, 19, 26 - here, the difference between two consecutive terms is 7.
Post answers in Comment.
(Your formula need not be a single formula. You can write multiple formulas to arrive at a solution. Also your formula need not be different from others as long as you have worked out your formula independently)
Download Practice File - https://lnkd.in/dMRR-Aqq
#excel, #excelchallenge, #powerquerychallenge, #daxchallenge, #m, #dax, #powerbi, #powerquery, #powerpivot, #sheets, #googlesheets, #data, #analytics, #businessintelligence, #finance, #office365, #python, #r
Excel BI’s LinkedIn Post
Aritmetic Progression w/ #powerquery. #bitanbit #powerbi
let
Source = Excel.CurrentWorkbook(){[Name="Input"]}[Content],
Solution = Table.TransformRows(Source, each
let
l = List.Transform(List.ReplaceValue(Text.Split([AP], ", "), "x", "0", Replacer.ReplaceText), each Number.From(_)),
p = List.PositionOf(l, 0)
in
if p = 0 then 2 * l{p + 1} - l{p + 2} else
if p = List.Count(l) - 1 then 2 * l{p - 1} - l{p - 2} else
(l{p - 1} + l{p + 1}) / 2
)
in
Solution
Hi to all
One option could be:
=MAP(A2:A7,LAMBDA(x,LET(v,TEXTSPLIT(x,", "),n,TOCOL(-v,2),-TREND(n,XMATCH(n,-v),XMATCH("x",v)))))
Blessings!
hi everyone, my proposal solution:
=BYROW(A2:A7, LAMBDA(r, LET(_m, TEXTSPLIT(r, ,", "),_n, MAX( TOROW( DROP(_m, 1)-DROP(_m, -1), 2)),_v, TAKE(_m, 1), IF(_v<>"x",_v+_n*(MATCH("x",_m,)-1),_n))))
Using almost the same method as the great Bo Rydobon y Taeyong Shin, but with the INTERCEPT and SLOPE functions
y = ax + b a=> SLOPE b=> INTERCEPT
=MAP(A2:A7,LAMBDA(a,LET(b,TEXTSPLIT(a,,", "),p,XMATCH("x",b),x,SEQUENCE(COUNTA(b)),y,IFERROR(b*1,b), p*SLOPE(y,x)+INTERCEPT(y,x))))
for A8 => 9, x, 27 B8=> 18
=MAP(A2:A8,LAMBDA(a,LET(o,{1,-1},b,TEXTSPLIT(a,,", "),AVERAGE(IFERROR(INDEX(b,XMATCH("x",b)+o)-o*MAX(IFERROR(DROP(b,1)-b,)),"")))))