Live data from Hacker News

Any positive number can be written as a sum of three palindromes

somethingorotherwhatever.com

91–100 of 114 posts

Re: Any positive number can be written as a sum of three palindromes

#93
post #9

Wonderful wonderful website. What happends to quirky people like this when they leave university and enter the industry?

from the website:

Newcastle University: I'm e-learning officer in the School of Mathematics and Statistics.

Most of my job involves writing the maths e-assessment system, Numbas. https://www.numbas.org.uk/

Re: Any positive number can be written as a sum of three palindromes

#94

Could this trick be used to improve compression? Since palindromes contain repeated digits by definition, perhaps they are more compressible than the original number? Of course, you'd have three numbers to compress instead of one...

Palindromes can be compressed 50% by using their symmetry. Representing a number as 3 palindromes would "compress" a number to 1.5 times the original size in the worst case. Obviously not an improvement.

If the number itself happens to be a palindrome, you can get down to 50%, but that's completely unrelated to this trick.

In general, it's impossible for a compression algorithm to losslessly compress all numbers to a shorter representation, it can only make some numbers shorter and others longer. (Pigeonhole principle: there are not enough short codes, so if you assign a shorter code to all numbers, some will get the same code, making the compression not lossless.)

Practical uses of compression are all about reducing the average length given a nonuniform probability distribution, so a palindrome-based compression scheme would only be useful if you could expect most numbers you're dealing with to be palindromes.

Re: Any positive number can be written as a sum of three palindromes

#95

For those wondering, this works in every base ≥ 5, according to the original paper: https://arxiv.org/abs/1602.06208v2 Every time I see something like this that is dependent on base-10 representation, I'm always curious to know whether it generalizes, or if it's a quirk specific to base-10 representation. For example, being able to tell if a number is divisible by 2 or 5 by only looking at the last digit.

Yeah, for example to check if a number is divisible by 3, we can use the digit sum and check if the result is divisible by 3, e.g. 153=(1)+(5)+(3)=9. This works in base-10, but we can generalize this by converting the dividend X into (3* X+1)-base then doing a digit sum. Let's say we want to check whether 238 is divisible by 17, so our base is 3* 17+1=52, 238 in base-52 is (4)+(30)=34=2* 17. If the convert-to-arbitra…

The convert to base X operation can't be cheaper than just dividing by X, can it?

Re: Any positive number can be written as a sum of three palindromes

#97
post #86

For those who are not impressed when they enter "3" and "444", try something like "8239419503490293592", and prepare to be blown away.

I figured it had small cases down so I immediately went for a fifteen digit number from /dev/urandom and was happy that it solved it perfectly. But I'm probably the exception. For those wondering how to generate random numbers, it's simple if you don't care about a little computational overhead: To explain the command: we read urandom into tr's stdin; tr translates (like "echo haha | tr a u"); with -d, tr deletes ins…

Cool one-liner to get random digits. On OSX, it produces the error "tr: Illegal byte sequence." The solution, per https://unix.stackexchange.com/q/45404, is to prepend the script with "LC_CTYPE=C ":

LC_CTYPE=C </dev/urandom tr -dc 0-9 | head -c 15

Re: Any positive number can be written as a sum of three palindromes

#98

For those wondering, this works in every base ≥ 5, according to the original paper: https://arxiv.org/abs/1602.06208v2 Every time I see something like this that is dependent on base-10 representation, I'm always curious to know whether it generalizes, or if it's a quirk specific to base-10 representation. For example, being able to tell if a number is divisible by 2 or 5 by only looking at the last digit.

And according to the Numberphile video ( https://www.youtube.com/watch?v=OKhacWQ2fCs ) there is a prior paper showing it for bases 2, 3, and 4

If you pause at 3:33 in the video and read the abstract, it actually says that numbers in base 2 require "at most 4 palindromes", rather than exactly 3, and "similar results" were found for bases 3 and 4. So it's not quite the same result as for bases of 5 or greater.

Re: Any positive number can be written as a sum of three palindromes

#99
post #61

Earlier quoted context omitted.

yeah....I don't see why this such an "impressive" trick.

OK tough guy, please give me three palindromic numbers that add up to 1,234,567. And don't use the trick! And don't use brute force!

1,234,567 + 0 + 0 = 1,234,567
Post reply on HN