Tonight, I decided to work on this month's Ponder This problem. It reads as follows:
James Tanton tweeted (https://twitter.com/jamestanton/status/293127359291330561) that "16 and 9 are each square numbers, and putting them together, 169, gives another square" and he then asked for other examples.
Our challenge this month is to find integers x, y, and z such that concatenating x^2 and y^2 gives z^2, and that z has at least four consecutive nines.
Update 2/6: the challenge stating that x,y and z should be non-zero.
The brute-force solution to this problem is pretty straightforward. I used Mathematica, but any programming language will work. In this program below, I generate lists of x^2 and y^2 values. I then convert those numbers to strings, concatenate the strings, convert those strings back into a number and check if the square root (z) is an integer. The (x,y,z) values that meet this condition are stored in the checkres list. To check is z contains more than four 9's, I convert z back into a string and look for any substring within z that contains four of more 9's. The (x,y,z) values that fit this criteria are stored in the results list.
The major hurdle in this problem is figuring out where in x-y parameter space to search. For x<1,000 and y<1,000, the are no more than two consecutive 9's and computing time starts to become an issue in Mathematica. For 1,000<x<10,000 and 1,000<y<10,000, there are three z values with three consecutive 9's. For a language such as Python or C++, the computing time would be significantly faster. I chose Mathematica for the ease of moving between data types.
I have not had much luck reducing the parameter space for viable solutions. Below is the brute force Mathematica code to show solutions with two or more consecutive 9's. The x or y value is at least 5 digits. I found some reliable ways of general solutions with three consecutive 9's, but the four 9 solutions were elusive for longer than I care to admit.
The major hurdle in this problem is figuring out where in x-y parameter space to search. For x<1,000 and y<1,000, the are no more than two consecutive 9's and computing time starts to become an issue in Mathematica. For 1,000<x<10,000 and 1,000<y<10,000, there are three z values with three consecutive 9's. For a language such as Python or C++, the computing time would be significantly faster. I chose Mathematica for the ease of moving between data types.
I have not had much luck reducing the parameter space for viable solutions. Below is the brute force Mathematica code to show solutions with two or more consecutive 9's. The x or y value is at least 5 digits. I found some reliable ways of general solutions with three consecutive 9's, but the four 9 solutions were elusive for longer than I care to admit.
After looking at it for a while longer, I found that numbers of the form x=49999... and y=99999.... will produce an increaseing string of 9's in z when their squares are concatenated. Here are the solutions for four through eleven 9's. I'm sure there are solutions I am missing, but I believe this solves the problem as stated.
Update: IBM has since posted an algebraic solution to this problem. They have not yet reviewed my solution since I accidentally sent them the wrong file at first.