 # Autumn Challenge - Three Cubes Sum

This is already a post from comp.lang.prolog and stackoverflow . But it seems it is reasonably challenging and could be fun. So I am also crossposting here.

It took Deep Thought 7½ million years to compute and check the answer, which turns out to be 42. But can we also compute via Prolog positive integer numbers x, y and z such that:

`````` x^3 + y^3 + 42 = z^3
``````

When I use a nearly quadratic algorithm, I can compute k=87. Here is an example code that does the computation and the time measurement is from a slow Mac laptop:

``````?- time((above(0,S), H is S//2, between(0,H,X),
Y is S-X, C is X^3+Y^3+87, rootrem(C,3,Z,0))).
% Up 70,783 ms, GC 612 ms, Threads 69,768 ms (Current 09/17/19 21:31:34)
X = 1972,
Y = 4126,
Z = 4271
``````

Other practical ways to speed up a Prolog solution so that we could reach k=42, or is this out of reach concerning computing time?

Edit 18.09.2019:
SWI-Prolog timing:

``````?- time((between(0,inf,S), H is S//2, between(0,H,X),
Y is S-X, C is X^3+Y^3+87, nth_integer_root_and_remainder(3,C,Z,0))).
% 37,217,891 inferences, 25.142 CPU in 25.408 seconds (99% CPU, 1480280 Lips)
X = 1972,
Y = 4126,
Z = 4271``````

You forgot to add the link: 42 is the new 33 - Numberphile

It shows a simplified version of the concept of how to dramatically simplify the problem, but because the suspected numbers to the solution are 10*16 or greater it sill is a brute force problem.

According to the Numberphile interview, they increased the computing power by an order of magnitude to go from 33 to 42. Rumor is they changed little about the algorithm, to the point where they’re not going to publish a paper about it. In the linked video Andrew says the changes made were to make it run at a larger scale, they’re focusing on the use of community powered parallel computing more.