All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Maximum Palindrome Count Muse (Posted on 2022-06-07) Difficulty: 4 of 5
A 3-digit decimal (base ten) Palindrome P is such that when expressed in base N, with N being a positive integer between 2 and 36 inclusively (base 10 excluded), at least one of them is also a palindrome.

M denotes the total count of such non base ten palindrome for a given value of decimal palindrome P.

Which value or values of P maximises the value of M?

No Solution Yet Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution No Subject | Comment 1 of 3
I get:
Pmax is 252
Mmax is 5 

252 yields 5 palindromes when changed to other bases as follows:
(base, palindrome):  {(5, 2002), (17, EE), (20, CC), (27, 99), (35, 77)}
in addition to base 10  (10, 252)

Here is the list of 3 digit palindromes and the number of "other base" palindromes for each:
101:0,
111:2,
121:3,
131:0,
141:1,
151:1,
161:1,
171:2,
181:1,
191:2,
202:0,
212:1,
222:2,
232:2,
242:3,
252:5,    <----   winner, winner, chicken dinner
262:0,
272:1,
282:2,
292:2,
303:0,
313:2,
323:2,
333:2,
343:3,
353:2,
363:1,
373:3,
383:0,
393:1,
404:0,
414:2,
424:0,
434:2,
444:2,
454:1,
464:3,
474:0,
484:2,
494:2,
505:2,
515:0,
525:2,
535:0,
545:1,
555:3,
565:1,
575:2,
585:2,
595:3,
606:0,
616:2,
626:3,
636:0,
646:2,
656:2,
666:4,
676:4,
686:1,
696:1,
707:0,
717:2,
727:1,
737:2,
747:0,
757:3,
767:1,
777:2,
787:3,
797:2,
808:0,
818:1,
828:2,
838:2,
848:1,
858:3,
868:2,
878:0,
888:2,
898:2,
909:1,
919:2,
929:1,
939:1,
949:1,
959:0,
969:0,
979:2,
989:3,
999:2

whichPals(252)
Outputs: [[5, '2002'], [17, 'EE'], [20, 'CC'], [27, '99'], [35, '77']]

----------
def base2base(n,a,b):
    """ input n which is a string of the number to be changed
    'a' is an integer representing the current base
    to be changed to base b 
    """
    def dec2base(i,base):
        """ INPUT integer in base 10, return string 
        of Base base equivalent. """
        convertString = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
        if i < base:
            return convertString[i]
        else:
            return dec2base(i//base,base) + convertString[i%base]
    if a == 10:
        return dec2base(int(n),b)
    if b == 10:
        return int(str(n),a)
    elif b != 10:
        return base2base(int(str(n),a),10,b)

def isPalindrome(n):
    """ return True if integer or string n is a palindrome """
    n = str(n)
    if n == n[::-1]:
        return True
    else:
        return False

def npals(p):
    if not isPalindrome(p):
        return 0
    m = 0
    for base in range(2,37):
        if base == 10:
            continue
        x = base2base(p,10,base)
        if isPalindrome(x):
            m += 1
    return m

def whichPals(p):
    if not isPalindrome(p):
        return 0
    m = 0
    answer = []
    for base in range(2,37):
        if base == 10:
            continue
        x = base2base(p,10,base)
        if isPalindrome(x):
            answer.append([base, x])
            m += 1
    return answer

ans = {}           # generate a dictionary shown above
for i in range(100,1000):
    if not isPalindrome(i):
        continue
    ans[i] = npals(i)

  Posted by Larry on 2022-06-07 10:06:07
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (11)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information