Wow. The version I posted yesterday that tries all the fractions using
Raul's floating point modification runs "over night". A translation of
a python solution found on the internet using a Farey sequence generator
(I think) runs in half a minute. Your approach---awesome!
On 06/16/2014 02:25 PM, [email protected] wrote:
Date: Mon, 16 Jun 2014 10:49:26 -0700
From: "'Pascal Jasmin' via Programming"<[email protected]>
To:"[email protected]" <[email protected]>
Subject: Re: [Jprogramming] Project Euler 73
Message-ID:
<[email protected]>
Content-Type: text/plain; charset=iso-8859-1
an explicit version for clarity
? ?rangei
[ + >:@] i.@- [
? ?2 rangei 5
2 3 4 5
dyad verb where y just holds the total so far.
4 : 'y + +/ 1= x +./ (>. x % 3) rangei (<. x % 2)'/ 2,~ 4+ i.11997
7295374 NB. includes 1/3 and 1/2
? ?timespacex '4 : ''y + +/ 1= x +./ (>. x % 3) rangei (<. x % 2)''/ 2,~ 4+
i.11997'
0.999943 446592
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm