On 7/12/07, Howell, Leonard W. (MSFC-VP62) <[EMAIL PROTECTED]> wrote:
Find integers a,b,c,d such that a^3 + b^3 + c^3 +d^3 =31
and in general, write a program to give the solutions to a^3 + b^3 + c^3 +d^3 
=k, k=1,..., 350.
Of course, some will be the empty set.
Anyone have an approach for this problem?

Hmm... well, first note that you can simply exhaustively try all
possible combinations -- not as a solution, but simply to get
a handle on the problem:
  $+/@>,{4#<^&3 i:4
6561

Of course, that's somewhat inefficient, as you can see when you
eliminate some redundancy from the result:
  $~.+/@>,{4#<^&3 i:4

But this approach is good enough to solve the "easy cases".  The
hard cases might said to be:
  (i.351)-.(#~ 350 >: ])(#~ 0 <: ])/:~~.+/@>,{4#<^&3 i:11
22 31 50 86 95 103 139 148 158 212 221 229 239 247 265 284 291 292 301 310

(I choose i: 11 as my stopping point because i:12 yields no further
results in the desired range.)

To solve the hard cases, you'd want to write a program which takes
advantage of the redundancy inherent in the problem.  Probably,
you would build up a repetoire of numbers reachable as cubes, as
sums of two cube, sums of three cubes and (finally) sums of four
cubes.  And, once a number is reachable you can ignore any subsequent
ways of achieving that number (for example, if you can reach a number
as a cube you can also reach it as a sum of several cubes by adding
zero to it).

That said, I'd have to investigate a bit more before I'd be prepared to
tackle this problem.

--
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to