Taking this a little further to solve the other difficult cases besides 31
not found in our initial
"exhaustive" search, we can find a solution for every positive integer < 350
except for 284:

  $ans
20301
  odc=. 50 86 148 239 265 284 292 301      NB. The other difficult cases <
350
  1 i.~"1 ans e."1 odc-"(0 1)ans                      NB. Possibs to add up
to difficult case
690 705 7904 1833 4460 20301 518 1052 NB. Only 3rd from end not found



On 7/12/07, Devon McCormick <[EMAIL PROTECTED]> wrote:

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

...
--
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