Working out the solutions for i.350 over a (limited) set of exhaustive
entries:
  6!:2 'ac=. ~./:~&.>,{4$<i:25'     NB. All combos from _25 to 25
9.959458
  $ac
316251
  ans=. +/&>ac^&.>3
  plot n350=. +/ans=/ i.350         NB. looks almost cyclic
  +/0=n350
9
  I. 0=n350                                    NB. So, 31 is especially
difficult
31 50 86 148 239 265 284 292 301

Does it help to reformulate the problem as:

(a^3)+(b^3) = 31 - ((c^3) + (d^3))

so we only have to consider pairs of cubes?  E.G.

  6!:2 'ac=. ~./:~&.>,{2$<i:100' NB. All pair combos from _100 to 100
0.12028791
  $ac
20301
  ans=. +/&>ac^&.>3
  *:#ans                 NB. How many pairs?
412130601           NB. Too many to consider all.
  +/ans e. 31-ans NB. Possibilities to add up to 31
10
  ans#~ans e. 31-ans
_244537 _193192 86528 _170368 _55393 55424 _86497 193223 244568 170399
  ac#~ans e. 31-ans
+-------+-------+------+-------+------+------+-------+------+------+-----+
|_56 _41|_56 _26|_56 64|_44 _44|_44 31|_44 52|_41 _26|_41 64|_26 64|31 52|
+-------+-------+------+-------+------+------+-------+------+------+-----+
  p31s=. ans#~ans e. 31-ans
  31=p31s +/ p31s
0 0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0 0
  wh31=. 31=p31s +/ p31s
  ($wh31)#:I.,wh31    NB. indexes of pairs to consider
0 8
1 7
2 6
3 9
4 5
5 4
6 2
7 1
8 0
9 3
  ;0 8{ac#~ans e. 31-ans    NB. Try the 1st pair...
_56 _41 _26 64
  +/3^~;0 8{ac#~ans e. 31-ans
31


On 7/12/07, Raul Miller <[EMAIL PROTECTED]> wrote:

On 7/12/07, Devon McCormick <[EMAIL PROTECTED]> wrote:
> One thing that makes the exhaustive solution difficult, if not
impossible,
> is that the numbers may be negative (as in John Randall's example
solution).

You can use a sequence generated by something like
   (<[EMAIL PROTECTED]: * _1 ^ 2&|)@>:@i.
instead of just plain i. to deal with that issue.

   (<[EMAIL PROTECTED]: * _1 ^ 2&|)@>:@i. 10
0 1 _1 2 _2 3 _3 4 _4 5

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




--
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to