Palindromes and Aliens

Number Theory Level pending

John, a space ambassador, is trying to negotiate a ceasefire between two aliens. Bazork stands 3 feet tall with 5 fingers in total. Gazorp is 9 feet in length and 6 inches in width with 3 fingers on each hand. The issue they have is religion. They both worship palindromes, and they each say that their own palindrome is the true one.

They try to explain this to John, and because they use different languages and number systems with different bases, John needs to use his translation machine. However, John gets confused because the numbers they each worship seem to be the same. He checks again and is still confused.

What is the smallest number this could be (in decimal representation)?

Hint: Bazork uses base 5 and Gazorp uses base 6, just as we humans use base 10 because of the number of our fingers.


Bonus: Generalize to all possible solutions (not just the smallest) in an equation.


The answer is 67.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Massimo 22
Nov 16, 2017

67 is the smallest number that is a palindrome in base 5 and base 6. Here is some code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
    def converter(n, base):

        digits = "0123456789ABCDEF"

        if n < base:
            return digits[n]
        else:
            return converter(n/base, base) + digits[n % base]


    def palindrome(num):

        if str(num) == str(num)[::-1]:
            return True

        else:
            return False


    for i in range(10, 10000):

        if palindrome(converter(i, 5)):

            if palindrome(converter(i, 6)):
                print i
                quit()

I'd like to know the bonus formula, and also any tips for uploading code to brilliant? It seems kinda ugly right now.

Which programming language is this?

Saksham Jain - 3 years, 6 months ago

Log in to reply

Python. If you want I can do it in C or Java or something?

massimo 22 - 3 years, 6 months ago

Log in to reply

no thanks i understood what you wanted to do .nice program

Saksham Jain - 3 years, 6 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...