Home » Find Double Base Palindromes

Find Double Base Palindromes

Find all double base Palindrome Numbers. A Palindrome number is that number which is same even when reversed. A Double Base Palindrome number is that Palindrome number which is Palindrome even when converted to binary. Example – 585 – This is a Palindrome number. Converted into binary this number is 1001001001. This binary is also a Palindrome number. Hence, 585 is a double base Palindrome number.

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

Solving the challenge of Find Double Base Palindromes with Power Query

Power Query solution 1 for Find Double Base Palindromes, proposed by Omid Motamedisedeh:
let
  Source  = Excel.CurrentWorkbook(){[Name = "Table1"]}[Content][Numbers], 
  Custom1 = List.Select(Source, each FX(Text.From(_))), 
  FX      = (x) => x = Text.Combine(List.Reverse(Text.ToList(x)))
in
  Custom1
Power Query solution 2 for Find Double Base Palindromes, proposed by Bo Rydobon 🇹🇭:
let
 Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
 Base = (n,b,r)=> let q = Number.IntegerDivide(n,b) ,m = Text.From(Number.Mod(n,b))&r in if q = 0 then m else @Base(q,b,m ),
 Ans = Table.SelectRows(Source,each let b = Base([Numbers],2,""), t = Text.From([Numbers]) in b=Text.Reverse(b) and t = Text.Reverse(t) )
in
 Ans

Thanks to Zoran Milokanović from this comment
https://www.linkedin.com/feed/update/urn:li:activity:7073871540802494464?commentUrn=urn%3Ali%3Acomment%3A%28activity%3A7073871540802494464%2C7077766511238500352%29&dashCommentUrn=urn%3Ali%3Afsd_comment%3A%287077766511238500352%2Curn%3Ali%3Aactivity%3A7073871540802494464%29


                    
                  
          
Power Query solution 3 for Find Double Base Palindromes, proposed by Bo Rydobon 🇹🇭:
let
  Source = Excel.CurrentWorkbook(){[Name = "Table1"]}[Content], 
  Ans = Table.SelectRows(
    Source, 
    each 
      let
        n = [Numbers], 
        t = Text.From(n), 
        b = List.Accumulate(
          List.Reverse({0 .. Number.RoundDown(Number.Log(n, 2))}), 
          {n, ""}, 
          (s, p) => {
            Number.Mod(s{0}, Number.Power(2, p)), 
            s{1} & Text.From(Number.IntegerDivide(s{0}, Number.Power(2, p)))
          }
        ){1}
      in
        b = Text.Reverse(b) and t = Text.Reverse(t)
  )
in
  Ans
Power Query solution 4 for Find Double Base Palindromes, proposed by Zoran Milokanović:
let
  Source = Excel.CurrentWorkbook(){[Name = "Input"]}[Content][Numbers], 
  S = List.Select(
    Source, 
    each 
      let
        n = Text.ToList(Text.From(_)), 
        b = List.Transform(
          {0 .. Number.RoundDown(Number.Log(_, 2))}, 
          (t) => Number.Mod(Number.IntegerDivide(_, Number.Power(2, t)), 2)
        )
      in
        n = List.Reverse(n) and b = List.Reverse(b)
  )
in
  S
Power Query solution 5 for Find Double Base Palindromes, proposed by Alejandro Simón 🇵🇦 🇪🇸:
let
  Source = Excel.CurrentWorkbook(){[Name = "Table1"]}[Content], 
  Sol = Table.SelectRows(
    Source, 
    each 
      let
        a = Number.From(Text.Reverse(Text.From([Numbers]))), 
        b = Number.RoundDown(Number.Log([Numbers], 2)), 
        c = Text.Combine(
          List.Reverse(
            List.Transform(
              {0 .. b}, 
              (x) => Text.From(Number.Mod(Number.RoundDown([Numbers] / Number.Power(2, x)), 2))
            )
          )
        ), 
        d = a = [Numbers] and c = Text.Reverse(c)
      in
        d
  )
in
  Sol
Power Query solution 6 for Find Double Base Palindromes, proposed by Luan Rodrigues:
let
  Fonte = Tabela1, 
  fil = Table.SelectRows(
    Fonte, 
    each (Text.Reverse(Text.From([Numbers])) = Text.From([Numbers])) = true
  ), 
  b = Table.AddColumn(
    fil, 
    "Personalizar", 
    each [
      a = Number.RoundDown(Number.Log([Numbers], 2)), 
      b = Text.Combine(
        List.Reverse(
          List.Transform(
            {0 .. a}, 
            (x) => Text.From(Number.Mod(Number.RoundDown([Numbers] / Number.Power(2, x)), 2))
          )
        )
      )
    ][b]
  ), 
  res = Table.SelectRows(
    b, 
    each (Text.Reverse(Text.From([Personalizar])) = Text.From([Personalizar])) = true
  )[[Numbers]]
in
  res
Power Query solution 7 for Find Double Base Palindromes, proposed by Venkata Rajesh:
let
  Source = Data, 
  Check = Table.AddColumn(
    Source, 
    "Check", 
    each [
      a = Text.From([Numbers]), 
      b = List.Transform(
        List.Generate(() => [Numbers], each _ > 0, each Number.IntegerDivide(_, 2)), 
        each Number.Mod(_, 2)
      ), 
      c = if a = Text.Reverse(a) and b = List.Reverse(b) then true else false
    ][c]
  ), 
  Output = Table.SelectRows(Check, each ([Check] = true))[[Numbers]]
in
  Output

Solving the challenge of Find Double Base Palindromes with Excel

Excel solution 1 for Find Double Base Palindromes, proposed by Bo Rydobon 🇹🇭:
=TOCOL(MAP(A2:A10,LAMBDA(n,LET(P,LAMBDA(a,CONCAT(MID(a,1+LEN(a)-SEQUENCE(LEN(a)),1))),n/(--P(n)=n)/(P(BASE(n,2))=BASE(n,2))))),3)
Excel solution 2 for Find Double Base Palindromes, proposed by Bo Rydobon 🇹🇭:
=TOCOL(MAP(A2:A10,LAMBDA(n,LET(P,LAMBDA(a,a&""=CONCAT(MID(a,99-SEQUENCE(98),1))),n/P(n)/P(BASE(n,2))))),3)
Excel solution 3 for Find Double Base Palindromes, proposed by Rick Rothstein:
=FILTER(A2:A10,MAP(A2:A10,LAMBDA(n,LET(f,LAMBDA(x,AND(MID(x,SEQUENCE(LEN(x)),1)=MID(x,SEQUENCE(LEN(x),,LEN(x),-1),1))),f(n)*f(BASE(n,2))))))
Excel solution 4 for Find Double Base Palindromes, proposed by John V.:
=FILTER(A2:A10,MAP(A2:A10,LAMBDA(n,LET(f,LAMBDA(x,x&""=CONCAT(MID(x,51-ROW(1:50),1))),f(n)*f(BASE(n,2))))))
Excel solution 5 for Find Double Base Palindromes, proposed by محمد حلمي:
=TOCOL(MAP(A2:A10,LAMBDA(a,LET(e,BASE(a,2),u,LAMBDA(x,x&""=CONCAT(MID(x,99-SEQUENCE(98),1))),a/(u(a)*u(e))))),2)
Excel solution 6 for Find Double Base Palindromes, proposed by محمد حلمي:
=TOCOL(MAP(A2:A10,LAMBDA(a,LET(u,LAMBDA(x,x&""=CONCAT(MID(x,99-SEQUENCE(98),1))),a/(u(a)*u(BASE(a,2)))))),2)
Excel solution 7 for Find Double Base Palindromes, proposed by محمد حلمي:
=TOCOL(MAP(A2:A10,LAMBDA(a,LET(
e,BASE(a,2),
r,LAMBDA(r,a,IF(a="","",
-(LEFT(a)=RIGHT(a))&
r(r,MID(LEFT(a,LEN(a)-1),2,99)))),
a/ISERR(FIND(0,r(r,a&e&e&a)))))),2)
Excel solution 8 for Find Double Base Palindromes, proposed by محمد حلمي:
=TOCOL(MAP(A2:A10,LAMBDA(a,LET(e,BASE(a,2),r,a&e&e&a,a/(r=CONCAT(MID(r,99-SEQUENCE(98),1)))))),2)
Excel solution 9 for Find Double Base Palindromes, proposed by محمد حلمي:
=TOCOL(MAP(A2:A10,LAMBDA(a,LET(e,BASE(a,2),i,99-SEQUENCE(98),a/((a&""=CONCAT(MID(a,i,1)))*
(e=CONCAT(MID(e,i,1))))))),2)
Excel solution 10 for Find Double Base Palindromes, proposed by Kris Jaganah:
=FILTER(A2:A10,MAP(A2:A10,LAMBDA(x,LET(a,LEN(x),b,--CONCAT(MID(x,SEQUENCE(a,,a,-1),1)),c,BASE(x,2),d,LEN(c),e,CONCAT(MID(c,SEQUENCE(d,,d,-1),1)),(x=b)*(e=c)))))
Excel solution 11 for Find Double Base Palindromes, proposed by Julian Poeltl:
=FILTER(A2:A10,MAP(A2:A10,LAMBDA(N,LET(IP,LAMBDA(A,LET(L,LEN(A),LEFT(A,L/2)=CONCAT(MID(A,SEQUENCE(L/2,,L,-1),1)))),IP(N)*IP(BASE(N,2))))))
Excel solution 12 for Find Double Base Palindromes, proposed by Timothée BLIOT:
=FILTER(A2:A10,MAP(A2:A10,LAMBDA(x,LET(IsP,LAMBDA(n,LET(A,LEFT(n,ROUNDDOWN(LEN(n)/2,0)),B,RIGHT(n,ROUNDDOWN(LEN(n)/2,0)),C,CONCAT(MID(B,SEQUENCE(LEN(B),,LEN(B),-1),1)),A=C)),IsP(BASE(x,2))*IsP(x)))))
Excel solution 13 for Find Double Base Palindromes, proposed by Sunny Baggu:
=LET(
 _e1, LAMBDA(x, MID(x, SEQUENCE(LEN(x)), 1)),
 _e2, LAMBDA(y,
 AND(TAKE(y, ROWS(y) / 2) = SORTBY(TAKE(y, -ROWS(y) / 2), -SEQUENCE(ROWS(y) / 2)))
 ),
 FILTER(A2:A10, MAP(A2:A10, BASE(A2:A10, 2), LAMBDA(a, b, AND(_e2(_e1(a)), _e2(_e1(b))))))
)
Excel solution 14 for Find Double Base Palindromes, proposed by LEONARD OCHEA 🇷🇴:
=LET(n,A2:A10,FILTER(n,MAP(n,LAMBDA(y,LET(b,BASE(y,2),F,LAMBDA(a,LET(l,LEN(a),CONCAT(MID(a,l+1-SEQUENCE(l),1)))),(--F(y)=y)*(F(b)=b))))))
Excel solution 15 for Find Double Base Palindromes, proposed by Asheesh Pahwa:
=b)*(d=c)))),FILTER(arr,Pg))
Excel solution 16 for Find Double Base Palindromes, proposed by Charles Roldan:
=LET(M, LAMBDA(f, f(f)), μ, LAMBDA(f, LAMBDA(x, MAP(x, f))), 
φ, LAMBDA(f, LAMBDA(x, FILTER(x, f(x)))), 
P, μ(M(LAMBDA(f, LAMBDA(x, IF(LEN(x) < 2, TRUE, IF(LEFT(x) = RIGHT(x), f(f)(MID(x, 2, LEN(x) - 2)))))))), 
f, φ(LAMBDA(x, NOT(MMULT(--NOT(P(BASE(x, {2,10}))), {1;1})))), f(A2:A10))
Excel solution 17 for Find Double Base Palindromes, proposed by JvdV -:
=LET(x;A2:A10;FILTER(x,MAP(x,BASE(x,2),LAMBDA(y,z,CONCAT(MID(VSTACK(y,z),100-SEQUENCE(,99),1))=y&z)))
Excel solution 18 for Find Double Base Palindromes, proposed by Julien Lacaze:
=LET(data,A2:A10,
isPalindrome,LAMBDA(t,MAP(t,LAMBDA(t,LET(a,MID(t,SEQUENCE(LEN(t)),1),b,INDEX(a,SEQUENCE(ROWS(a),,ROWS(a),-1)),--AND(a=b))))),
bin,BASE(data,2),FILTER(data,isPalindrome(data)*isPalindrome(bin)))
Excel solution 19 for Find Double Base Palindromes, proposed by Pieter de Bruijn:
=LET(a,A2:A10,FILTER(a,MAP(a,BASE(a,2),LAMBDA(x,y,(x=--CONCAT(SORTBY(MID(x,SEQUENCE(LEN(x)),1),-SEQUENCE(LEN(x)))))*(y=CONCAT(SORTBY(MID(y,SEQUENCE(LEN(y)),1),-SEQUENCE(LEN(y)))))))))
Excel solution 20 for Find Double Base Palindromes, proposed by Pieter de Bruijn:
=LET(x,A2:A10,TOCOL(x/MAP(x,BASE(x,2),LAMBDA(y,z,CONCAT(MID(VSTACK(y,z),99-COLUMN(A:CT),1))=y&z)),3))
Excel solution 21 for Find Double Base Palindromes, proposed by Giorgi Goderdzishvili:
=LET(
numbers,A2:A10,
binary, BASE(numbers,2),
length, LEN(numbers),
lengthB, LEN(binary),
isPalindromN,
MAP(numbers,length, LAMBDA(n,l,
SUM(--(MID(n,SEQUENCE(l),1)=MID(n,SEQUENCE(l,,l,-1),1)))=l)),
isPalindromB,MAP(binary,lengthB, LAMBDA(b,l,
SUM(--(MID(b,SEQUENCE(l),1)=MID(b,SEQUENCE(l,,l,-1),1)))=l)),
FILTER(numbers,isPalindromB*isPalindromN))
Excel solution 22 for Find Double Base Palindromes, proposed by Quadri Olayinka Atharu:
=LET(_n,A2:A10,
r,LAMBDA(x,CONCAT(MID(x,SORT(SEQUENCE(LEN(x)),,-1),1))),
_c1,--MAP(_n,LAMBDA(y,r(y)))=_n,
_c2,MAP(_n,LAMBDA(x,LET(a,BASE(x,2),r(a)=a))),
FILTER(_n,_c1*_c2))
Excel solution 23 for Find Double Base Palindromes, proposed by Paolo Pozzoli:
=LET(nums;A2:A10;flt;FILTER(nums;BYROW(nums;LAMBDA(n;BASE(n;2)=CONCAT(MID(BASE(n;2);SEQUENCE(LEN(BASE(n;2));;LEN(BASE(n;2));-1);1)))));flt)
Excel solution 24 for Find Double Base Palindromes, proposed by Henriette Hamer:
=FILTER(A2:A10;MAP(A2:A10;LAMBDA(numbers;
LET(_data;numbers;
_bin;BASE(_data;2);
_lendec;LEN(_data);
_seqdec;ROUNDDOWN(_lendec/2;0);
_lenbin;LEN(_bin);
_seqbin;ROUNDDOWN(_lenbin/2;0);
AND(
 AND(MID(_data;SEQUENCE(_seqdec;;1;1);1)=MID(_data;_lendec-SEQUENCE(_seqdec;;0;1);1));
 AND(MID(_bin;SEQUENCE(_seqbin;;1;1);1)=MID(_bin;_lenbin-SEQUENCE(_seqbin;;0;1);1))
 )
))))
with a little peek at another comment, for the base(n,x)
Excel solution 25 for Find Double Base Palindromes, proposed by Hussain Ali Nasser:
=FILTER(
 A2:A10,
 BYROW(
 A2:A10,
 LAMBDA(_range,
 LET(
 _binary, BASE(_range, 2),
 _binlen, LEN(_binary),
 _numlen, LEN(_range),
 _nsplit, MID(_range, SEQUENCE(_numlen), 1),
 _nrevsplit, MID(_range, SEQUENCE(_numlen, , _numlen, -1), 1),
 _bsplit, MID(_binary, SEQUENCE(_binlen), 1),
 _brevsplit, MID(_binary, SEQUENCE(_binlen, , _binlen, -1), 1),
 _checkmatch, PRODUCT(--(_nsplit = _nrevsplit)) +
 PRODUCT(--(_bsplit = _brevsplit)),
 _checkmatch
 )
 )
 ) = 2
)
Excel solution 26 for Find Double Base Palindromes, proposed by Amr Tawfik CMA®,FMVA,Lean Coach:
=FILTER(A2:A10,A2:A10=--MAP(A2:A1&0,LAMBDA(x,CONCAT(SORTBY(MID(x,SEQUENCE(LEN(x),,1,1),1),SEQUENCE(LEN(x),,1,1),-1))))=TRUE)

Solving the challenge of Find Double Base Palindromes with Python in Excel

Python in Excel solution 1 for Find Double Base Palindromes, proposed by Alejandro Campos:
def is_p(s): return s == s[::-1]
df = pd.DataFrame([n for n in xl("A2:A10")[0] if is_p(str(n)) 
 and is_p(bin(n)[2:])], columns=['Double Base Palindromes'])

Solving the challenge of Find Double Base Palindromes with Excel VBA

Excel VBA solution 1 for Find Double Base Palindromes, proposed by Nicolas Micot:
=FILTRE(A2:A10;(A2:A10=f_inverse(A2:A10)+0)*(BASE(A2:A10;2)=f_inverse(BASE(A2:A10;2))))
VBA function used:
Function f_inverse(valeurs) As Variant
Dim tableau As Variant
Dim valeur As String
tableau = valeurs
If Not IsArray(tableau) Then
 ReDim tableau(1 To 1, 1 To 1)
 tableau(1, 1) = Plage
End If
For a = 1 To UBound(tableau, 1)
 For b = 1 To UBound(tableau, 2)
 valeur = tableau(a, b)
 tableau(a, b) = ""
 For i = Len(valeur) To 1 Step -1
 tableau(a, b) = tableau(a, b) & Mid(valeur, i, 1)
 Next i
 Next b
Next a
f_inverse = tableau
End Function
                    
                  

&&

Leave a Reply