Home » List All Dudeney Numbers

List All Dudeney Numbers

A Dudeney number is a positive integer that is a perfect cube such that the sum of its decimal digits is equal to the cube root of the number. Ex. 512 – cube root is 8 and sum of digits is 5+1+2 = 8 There are only 6 Dudeny numbers and find all those 6 Dudeny numbers.

📌 Challenge Details and Links
ExcelBI Excel Challenge Number: 204
Challenge Difficulty: ⭐️
📥Download Sample File
📥Link to the solutions on LinkedIn

Solving the challenge of List All Dudeney Numbers with Power Query

Power Query solution 1 for List All Dudeney Numbers, proposed by Bo Rydobon 🇹🇭:
let
  Source = List.Transform(
    List.Select(
      {1 .. 99}, 
      each 
        let
          q = Number.Power(_, 3)
        in
          List.Sum(List.Transform(Text.ToList(Text.From(q)), Number.From)) = _
    ), 
    each Number.Power(_, 3)
  )
in
  Source
Power Query solution 2 for List All Dudeney Numbers, proposed by Zoran Milokanović:
let
  Source = List.Transform(
    List.Select(
      List.Generate(
        () => [N = 1, F = true, C = 1], 
        each [C] <= 6, 
        each [
          N = [N] + 1, 
          F = (
            Number.Round(Number.Power(N, 1 / 3), 4)
              = List.Sum(List.Transform(Text.ToList(Text.From(N)), Number.From))
          ), 
          C = [C] + Number.From(F) + Number.From([C] = 6)
        ]
      ), 
      each [F]
    ), 
    each [N]
  )
in
  Source
Power Query solution 3 for List All Dudeney Numbers, proposed by Alejandro Simón 🇵🇦 🇪🇸:
let
  Source = List.Generate(
    () => [x = 0, y = 1, z = {0}], 
    each [x] < 7, 
    each [
      y = [y] + 1, 
      z = List.Transform(
        {[y]}, 
        (n) =>
          let
            a = Text.ToList(Text.From(n)), 
            b = List.Sum(List.Transform(a, Number.From)), 
            c = {Number.Power(b, 3)} & {[y]}, 
            d = if c{0} <> c{1} then null else [y]
          in
            d
      ), 
      x = if [z]{0} = null then [x] else [x] + 1
    ], 
    each [z]
  ), 
  Sol = List.Select(List.Transform(List.Skip(Source), each _{0}), each _ <> null)
in
  Sol
Power Query solution 4 for List All Dudeney Numbers, proposed by Alejandro Simón 🇵🇦 🇪🇸:
let
  Source = List.Select(
    List.Transform(
      {1 .. Number.Power(40, 3)}, 
      (x) =>
        let
          a = Number.Power(x, 3), 
          b = List.Sum(List.Transform(Text.ToList(Text.From(a)), Number.From)), 
          c = {a / Number.Power(x, 2)} & {b}, 
          d = if c{0} = c{1} then a else null
        in
          d
    ), 
    each _ <> null
  )
in
  Source
Power Query solution 5 for List All Dudeney Numbers, proposed by Brian Julius:
let
  Source = Table.FromList({1 .. 46}, Splitter.SplitByNothing(), {"Number"}, null, ExtraValues.Error), 
  SumOfCubeDigits = Table.AddColumn(
    Source, 
    "SumOfCubeDigits", 
    each [
      a = [Number], 
      b = Number.Power(a, 3), 
      c = Text.ToList(Text.From(b)), 
      d = List.Transform(c, each Number.From(_)), 
      e = List.Sum(d)
    ][e]
  ), 
  Filter = Table.SelectColumns(
    Table.SelectRows(SumOfCubeDigits, each [Number] = [SumOfCubeDigits]), 
    "Number"
  )
in
  Filter
Power Query solution 6 for List All Dudeney Numbers, proposed by Guillermo Arroyo:
let
  a = (x, y) =>
    if List.Count(y) = 6 then
      y
    else
      @a(
        x + 1, 
        if x
          = List.Sum(
            List.Transform(Text.ToList(Text.From(Number.Power(x, 3))), each Number.FromText(_))
          )
        then
          List.Combine({y, {Number.Power(x, 3)}})
        else
          y
      )
in
  a(2, {1})
Power Query solution 7 for List All Dudeney Numbers, proposed by Tyler N.:
Table.SelectRows(
  Table.FromRecords(
    List.Generate(
      () => [a = 1, d = 1], 
      each [a] < 20000, 
      each [
        a = [a] + 1, 
        d = 
          if Number.Round(Number.Power([a] + 1, (1 / 3)), 10)
            = List.Sum(List.Transform(Text.ToList(Text.From([a] + 1)), each Number.From(_)))
          then
            1
          else
            0
      ], 
      each [[a], [d]]
    )
  ), 
  each [d] = 1
)[a]

Solving the challenge of List All Dudeney Numbers with Excel

Excel solution 1 for List All Dudeney Numbers, proposed by Bo Rydobon 🇹🇭:
=TOCOL(MAP(SEQUENCE(99),LAMBDA(s,s^3/(s=SUM(--MID(s^3,SEQUENCE(LEN(s^3)),1))))),3)
Excel solution 2 for List All Dudeney Numbers, proposed by Rick Rothstein:
=LET(n,SEQUENCE(1000),FILTER(n^3,MAP(n,LAMBDA(x,x=SUM(0+MID(x^3,SEQUENCE(,LEN(x^3)),1))))))
Excel solution 3 for List All Dudeney Numbers, proposed by John V.:
=LET(n,ROW(1:30),FILTER(n^3,MMULT(--MID(n^3/1%%,{1,2,3,4,5},1),{1;1;1;1;1})=n))
Excel solution 4 for List All Dudeney Numbers, proposed by John V.:
=LET(n,ROW(1:30),FILTER(n^3,MMULT(--(0&MID(n^3,TOROW(n),1)),n^0)=n))
Excel solution 5 for List All Dudeney Numbers, proposed by محمد حلمي:
=LET(r,SEQUENCE(20000),FILTER(r,r^(1/3)=MMULT((0&MID(r,{1,2,3,4,5},1))+0,{1;1;1;1;1})))
Excel solution 6 for List All Dudeney Numbers, proposed by Kris Jaganah:
=LET(a,SEQUENCE(100),b,a^3,c,BYROW(DROP(IFNA(REDUCE("",b,LAMBDA(x,y,VSTACK(x,--MID(y,SEQUENCE(,LEN(y)),1)))),""),1),LAMBDA(z,SUM(z))),FILTER(b,c=a))
Excel solution 7 for List All Dudeney Numbers, proposed by Alejandro Campos:
=LET(
 s, SEQUENCE(1000) ^ 3,
 m, MAP(s, LAMBDA(x, SUM(--MID(x, SEQUENCE(LEN(x)), 1)))),
 r, ROUND(POWER(s, 0.3333333), 0),
 FILTER(s, m = r)
)
Excel solution 8 for List All Dudeney Numbers, proposed by Alejandro Campos:
==(c:=round(n**(1/3)))and c**3==n)
Excel solution 9 for List All Dudeney Numbers, proposed by Timothée BLIOT:
=LET(A,SEQUENCE(10^5),FILTER(A,(MAP(A,LAMBDA(x,SUM(MID(x,SEQUENCE(LEN(x)),1)*1)=x^(1/3))))))
Excel solution 10 for List All Dudeney Numbers, proposed by Sunny Baggu:
=LET(
 _num, SEQUENCE(20000),
 _sum, MAP(_num, LAMBDA(a, SUM(MID(a, SEQUENCE(LEN(a)), 1) + 0))),
 _crt, POWER(_num, 1 / 3),
 _cri, _sum = _crt,
 FILTER(_num, _cri)
)
Excel solution 11 for List All Dudeney Numbers, proposed by Sunny Baggu:
=TOCOL(
 MAP(
 SEQUENCE(20000),
 LAMBDA(s, IF(s ^ (1 / 3) = SUM(MID(s, SEQUENCE(LEN(s)), 1) + 0), s, NA()))
 ),
 3
)
Excel solution 12 for List All Dudeney Numbers, proposed by Md. Zohurul Islam:
=LET(n,SEQUENCE(99999),
u,MAP(n,LAMBDA(x,SUM(ABS(MID(x,SEQUENCE(LEN(x)),1)))=x^(1/3))),
v,FILTER(n,u),
v)
Excel solution 13 for List All Dudeney Numbers, proposed by Charles Roldan:
=LET(
 M, LAMBDA(f, f(f)),

 A, LAMBDA(f, LAMBDA(x, [y], SCAN(y, x, f))),

 K, LAMBDA(f, LAMBDA(x, [y], f(x))),

 S, LAMBDA(f, M(LAMBDA(g, LAMBDA(x,
 IF(f(x + 1), x + 1, g(g)(x + 1)))))),


 d, M(LAMBDA(g, LAMBDA(x,
 IF(LEN(x), LEFT(x) + g(g)(REPLACE(x, 1, 1, )))))),

 f, A(K(S(LAMBDA(n, n = d(n ^ 3))))),

 f(SEQUENCE(6)) ^ 3
)
Excel solution 14 for List All Dudeney Numbers, proposed by Charles Roldan:
=LET(M, LAMBDA(g, g(g)), 

Succ, LAMBDA(f, M(LAMBDA(g, LAMBDA(n, 
IF(f(n + 1), n + 1, g(g)(n + 1)))))), 

_sumDigits, M(LAMBDA(g, LAMBDA(n, 
MOD(n, 10) + IF(n, g(g)(QUOTIENT(n, 10)))))), 

_isDudeneyRoot, LAMBDA(n, n = _sumDigits(n ^ 3)), 

SixRoots, SCAN(, SEQUENCE(6), LAMBDA(n,_, Succ(_isDudeneyRoot)(n))), 

SixRoots ^ 3)
Excel solution 15 for List All Dudeney Numbers, proposed by JvdV -:
=LET(a,ROW(1:20000),FILTER(a,MMULT(--(0&MID(a,{1,2,3,4,5},1)),{1;1;1;1;1})^3=a))
Excel solution 16 for List All Dudeney Numbers, proposed by Abhishek Kumar Jain:
=FILTER(SEQUENCE(999999),MAP(SEQUENCE(999999),LAMBDA(X,SUM(--MID(X,SEQUENCE(,LEN(X)),1))=X^(1/3))))
Excel solution 17 for List All Dudeney Numbers, proposed by Guillermo Arroyo:
=LET(f;LAMBDA(a;b;c;IF(ROWS(c)=6;c;a(a;b+1;IF(b=SUM(--MID(b^3;SEQUENCE(LEN(b^3));1));VSTACK(c;b^3);c))));f(f;2;1))
Excel solution 18 for List All Dudeney Numbers, proposed by Daniel Garzia:
=LET(s,SEQUENCE(99999),FILTER(s,(s^(1/3))=MAP(s,LAMBDA(x,SUM(--MID(x,SEQUENCE(LEN(x)),1))))))
Excel solution 19 for List All Dudeney Numbers, proposed by Rayan S.:
=LET(
 list, MAP(
 SEQUENCE(20000),
 LAMBDA(a,
 LET(
 x, SUM(MID(a, SEQUENCE(LEN(a)), 1) + 0),
 y, POWER(a, 1 / 3),
 IF(x = y, a, 0)
 )
 )
 ),
 FILTER(list, list > 0)
)
Excel solution 20 for List All Dudeney Numbers, proposed by Hussain Ali Nasser:
=TOCOL(MAP(SEQUENCE(20000),LAMBDA(_range,LET(
_split,--MID(_range,SEQUENCE(LEN(_range)),1),
_cuberoot,_range^(1/3),
_check,SUM(_split)=_cuberoot,
FILTER(_range,_check)
))),3)

&&&

Leave a Reply