Each of A, B, and C is a different
zeroless pandigital number that satisfy this equation:
A*B=C2
Determine the minimum value of C.
That is a great compliment, Charlie; thank you.
Regarding algorithms, my first thought was to try every combination of 2 pandigitals, take the square root, and check. I quickly saw one could just make a list of the squares and eliminate the square root step. But still O(n^2) to check all the pandigital combinations.
Next, {tl;dr I ended up not doing this} I thought about manipulating A and B so I could get the difference of 2 squares and then try to match the squares to a Pythagorean triple. I had forgotten about Euclid's formula for generating Pythagorean triples, but rediscovered it.
Let mean = (a+b)/2 and diff = (a-b)/2
(mean+diff)(mean-diff) = a * b = c^2
mean^2 - diff^2 = c^2
diff^2 + c^2 = mean^2 where
c is pandigital, and
mean is the midpoint between a and b, and
diff is the distance from the mean to either a or b
Euclid's formula for generating a Pythagorean triple x^2 + y^2 = z^2
For positive integers m,n m>n
x = m^2 - n^2 ... y = 2mn ... z = m^2 + n^2 of which x or y is pandigital
But I abandoned this quest and stopped working on it. This was several days ago.
Then this morning after the problem posted, I just came up with the algorithm which ended up working. I think sometimes the algorithm ideas have to churn around in the background before they gel into butter.
|
Posted by Larry
on 2023-01-06 15:07:33 |