Sorry - Just a reminder that Project Euler's own problem-specific
discussion
forum maintains the convention of not disclosing the solution to those who
haven't yet solved it.
The problems' header pages state:
"If you have already solved the problem it will display both the problem
and the
corre
On Tue, Mar 14, 2017 at 8:12 PM, 'Jon Hough' via Programming <
> >> [email protected]> wrote:
> >>
> >>> I just tried it and got the right answer. But my approach is
> essentially
> >>> brute force:
> >>> I basically stringifie
gt;> I basically stringified (":) the totient result, sorted it, and compared
>>> to the sorted stringified original number.
>>>
>>> I can be more specific if you like.
>>>
>>> Regards,
>>> Jon
>>> --
gt; > Also, I stole totient from J phrases too.
> >
> >
> > On Wed, 3/15/17, Don Guinn wrote:
> >
> > Subject: Re: [Jprogramming] Project Euler
> > To: "Programming forum"
> > Date: Wednesday, Mar
e.com> wrote:
>>
>> I just tried it and got the right answer. But my approach is essentially
>>> brute force:
>>> I basically stringified (":) the totient result, sorted it, and compared
>>> to the sorted stringified original number.
>>>
>
be more specific if you like.
Regards,
Jon
On Wed, 3/15/17, Don Guinn wrote:
Subject: [Jprogramming] Project Euler
To: "Programming forum"
Date: Wednesday, March 15, 2017, 9:37 AM
Has anyone out there solved problem
70? I have worked it two ways which
o divide them by the totient
> and find which number is the minimum.
>
> Also, I stole totient from J phrases too.
>
> --------
> On Wed, 3/15/17, Don Guinn wrote:
>
> Subject: Re: [Jprogramming] Project Euler
> To: "Programming foru
+ 1.
If you want to look at my answer, it is here:
https://github.com/jonghough/projecteulersolutions/blob/master/answers/projecteuler70.ijs
On Wed, 3/15/17, 'Jon Hough' via Programming wrote:
Subject: Re: [Jprogramming] Project Euler
ions of their totients, you
need to divide them by the totient
and find which number is the minimum.
Also, I stole totient from J phrases too.
On Wed, 3/15/17, Don Guinn wrote:
Subject: Re: [Jprogramming] Project Euler
To: "Programming forum"
ore specific if you like.
>
> Regards,
> Jon
> ----
> On Wed, 3/15/17, Don Guinn wrote:
>
> Subject: [Jprogramming] Project Euler
> To: "Programming forum"
> Date: Wednesday, March 15, 2017, 9:37 AM
>
> Has anyone out there solved problem
>
,
Jon
On Wed, 3/15/17, Don Guinn wrote:
Subject: [Jprogramming] Project Euler
To: "Programming forum"
Date: Wednesday, March 15, 2017, 9:37 AM
Has anyone out there solved problem
70? I have worked it two ways which
give the same answer but it is given as incorrect. I don
Has anyone out there solved problem 70? I have worked it two ways which
give the same answer but it is given as incorrect. I don't want to divulge
what I did as that is against their rules. I must be missing something and
presenting the wrong number for the result. Or is it possible that their
answ
(Unicode APL chars in this message! and a spoiler if you haven't yet
found the solution!)
I love showing off the APL (from the original book) solution for this
to people who have heard nothing of array-based languages:
V +.× ∊ ∨.= N ∘.| V
which finds the sum of the numbers in the vector V whi
;t
understand the full dictionary at first, but its much easier to pick up the
shortcuts after focusing on the core operators.
- Original Message -
From: Geoff Canyon
To: [email protected]
Sent: Friday, May 6, 2016 12:03 PM
Subject: Re: [Jprogramming] Project Euler 1
On F
From: Geoff Canyon
To:[email protected]
Subject: Re: [Jprogramming] Project Euler 1
Message-ID:
Content-Type: text/plain; charset=UTF-8
On Fri, May 6, 2016 at 4:43 AM, Martin Kreuzer wrote:
>At that stage I realized that (/) isn't only "Insert" but also used to
>
On Fri, May 6, 2016 at 4:43 AM, Martin Kreuzer wrote:
> At that stage I realized that (/) isn't only "Insert" but also used to
> force a "Table":
>
Yep, this was new to me as well, as evidenced by my original awkward |"0 1
construction.
--
): 3 5
>> 7 (0=(|/i.)) 25 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 1 0 0 0 0
>> 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0
>> 0 0 0 1 0 0 0 3 5 7 (0 +./ .=(|/i.)) 25 1 0 0 1 0 1 1 1 0 1 1 0 1 0 1 1
>> 0 0 1 0 1 1 0 0 1 Thanks
(0 +./
.=(|/i.)) 25 1 0 0 1 0 1 1 1 0 1 1 0 1 0 1 1 0 0 1 0 1 1 0 0 1
Thanks for your patience ... -M At 2016-05-05 22:03, you wrote: > >
3 5 (0 +./ .= (|/ i.)) 20 the ".=" is hard to read. Its >
equivalent to ". =" or in this case 3 5 (0 +./@:= (|/ i.)) 20
-
ts
equivalent to ". =" or in this case 3 5 (0 +./@:= (|/ i.)) 20 -
Original Message ----- From: Geoff Canyon To:
[email protected] Sent: Thursday, May 5, 2016 5:54 PM
Subject: Re: [Jprogramming] Project Euler 1 So there are a few
learning opportunities here -- euphemism for thin
> 3 5 (0 +./ .= (|/ i.)) 20
the ".=" is hard to read. Its equivalent to ". =" or in this case
3 5 (0 +./@:= (|/ i.)) 20
- Original Message -
From: Geoff Canyon
To: [email protected]
Sent: Thursday, May 5, 2016 5:54 PM
Subject: Re: [Jprogramming] Projec
+./ .= is rather like +/ .*
For example:
2 +/ .* 3 5 7
30
Here, we multiply 2 by each of 3, 5 and 7, then we add up the results.
Similarly,
0 +./ .= 0 1 2 3
1
Here, we check if 0 is equal to each of 0, 1, 2 and 3 and then we or
up the results.
For more detail on this combining mechanism
That is a dot product, a scalar zero on the left and a matrix on the right.
If you follow the rules of a dot product the scalar zero is treated as (1
2$0) giving the result.
On Thu, May 5, 2016 at 3:54 PM, Geoff Canyon wrote:
> So there are a few learning opportunities here -- euphemism for thin
So there are a few learning opportunities here -- euphemism for things I
don't understand ;-)
I get how adding 0 = transforms the modulo results into a 1 for "divisible"
and 0 for "not divisible":
3 5 (0 = (|/ i.)) 20
1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0 0 1 0
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
Thinking this through just a little bit more:
NB. brute force adverb:
pe1Ab=: 1 :'m&([:+/@I. 0 +./ .= (|/ i.))'
NB. moebius adverb:
mu=: (1 _1 0 */@:{~ 2 <. _ q: ])"0
mf=: -.&0@(- * mu)@(, ~.@,@:(*/)~)
pe1Am=: 1 :'(mf m) +/@([ * 2 ! 1 + (<.@% |)~) <:'
3 5 pe1Ab 1000
233168
3 5 pe1Am 1000
2
If this matters:
mu=: 1 _1 0 */@:{~ 2 <. _ q: ] NB. moebius
But it's maybe simpler to describe this as removing the "double
counting" which would result from counting multiples of 15 twice (once
for multiples of 3 and the other as multiples of 5).
--
Raul
On Thu, May 5, 2016 at 10:03 AM, M
Yes, quite right! You're my conscience as ever, Raul.
Sorry - I misremembered and didn't check.
Moebius mu(n) is 1 for 3 and 5, _1 for 3*5=15, and 0 for powers higher
than one of 3 and 5 and their products, so (eg) 0 for 25, 27 etc.
Also, 99 is the upper inclusive bound.
So:
+/99 (]*2!>
On Thu, May 5, 2016 at 4:31 AM, Mike Day wrote:
> +/1683 1050 _594 315 _250 162 _135
> 2231
Er... is that the right answer, somehow?
Thanks,
--
Raul
--
For information about J forums see http://www.jsoftware.com/forums.htm
I continue to try to solve Project Euler problems with J, but you'll
find that it's generally
hard to solve with a naturally APL/J approach. I sometimes lose track
of precision and
resort to Pari/GP.
I think they expect you to use something like the Moebius theorem in
this kind of problem.
looks fine, with similar structure,
3 5 (i.@] #~ +./@:(0&=)@:(|"0 1 i.)) 19
or shorter
3 5 (i.@] #~ +./@:(0&=)@:(|/ i.)) 19
- Original Message -
From: Geoff Canyon
To: [email protected]
Sent: Wednesday, May 4, 2016 10:35 PM
Subject: [Jprogramming] Project
On Wed, May 4, 2016 at 10:35 PM, Geoff Canyon wrote:
> So I tried to write code to solve the general case of Project Euler problem
> 1. The problem given is to find the sum of all the positive integers less
> than 1000 that are divisible by 3 or 5. Obviously the specific case is
> highly optimizab
I used modulo outer product |/ found which ones equal zero and then anded the
rows of the matrix together to find the numbers that have both 3 and 5 as
divisors
I. (*./ (0 = 3 5 |/i.1000))
0 15 30 45 60 75 90 105 120 135 150 165 180 195 210 . . .
to generalize into a tacit I cheat and use 13
So I tried to write code to solve the general case of Project Euler problem
1. The problem given is to find the sum of all the positive integers less
than 1000 that are divisible by 3 or 5. Obviously the specific case is
highly optimizable. But I wanted to solve the general, with any number of
divi
Sent from my Verizon Wireless 4G LTE smartphone
Original message From: Raul Miller
Date:10/14/2014 10:04 AM (GMT-05:00)
To: Programming forum
Subject: Re: [Jprogramming] Project Euler 85, Python and J
Your approach looks very sensible. But I am curious about this
Sent from my Verizon Wireless 4G LTE smartphone
Original message From: Raul Miller
Date:10/14/2014 10:04 AM (GMT-05:00)
To: Programming forum
Subject: Re: [Jprogramming] Project Euler 85, Python and J
Your approach looks very sensible. But I am curious about this
Whoops!
Yes, I'd been using I. in a slightly different structure,
with a two-column table of lower and upper bounds on
n for every m, and had forgotten to change it to (i. <./)
for the vector form with all lower bounds followed by
all upper bounds; I'd found it slightly less messy,
and (i.<./)
400 sum 7 ff 7
>> 400 sum f 6
>> 400 sum f 7
>> 400 sum f 8
>> 6 ff 6
>> 400 sum 6 ff 6
>>
>> 2e6 < 2e6 sum 52 ff 52
>> 2e6 < 2e6 sum 53 ff 53
>> 2e6 < 2e6 sum 54 ff 54
>> 2e6 sum f 53
>> 2e6 sum f 54
>> 2e6 sum f 55
>&
[mailto:[email protected]] On Behalf Of Raul Miller
Sent: Saturday, October 11, 2014 6:10 PM
To: Programming forum
Subject: Re: [Jprogramming] Project Euler 85, Python and J
I understand that boxed index lists can be used to index multi-dimensioned
arrays. And that can be a conv
>
> > I had ( for some reason )
> >
> > arr =: 10 10 $ >: i. 100
> >
> >
> > So I have a 10 by 10 matrix of all positive ints up to 100.
> >
> >
> > primelist clearly will not work on arr. But if I want to return the list
> > of primes, as
d only
> if the sum of the (i, j) indices are prime (just a random example).
>
>
> In procedural python this could be quickly done with a double for-loop and
> a prime test. In J this type of problem still escapes me.
>
>
>
> > Date: Fri, 10 Oct 2014 19:35:26 -0400
>
To: [email protected]
Subject: Re: [Jprogramming] Project Euler 85, Python and J
countRects=: */@(2 ! >:) NB. How many pairs each of vertical
* horizontal lines
getSizes=: ,@(>:/~) # [: ,/ ,"0/~NB. All pairs of i. y
idxClosest=: 4 : '(i. <./)@(
[email protected]] on behalf of Jon Hough
[[email protected]]
Sent: Saturday, October 11, 2014 07:43
To: [email protected]
Subject: Re: [Jprogramming] Project Euler 85, Python and J
Also, regarding Ben Gorte's
Idot =: $ #: I.@:,
This is an equivalent of I. for higher dim
[email protected]
[mailto:[email protected]] On Behalf Of Raul
Miller
Sent: Saturday, October 11, 2014 6:10 PM
To: Programming forum
Subject: Re: [Jprogramming] Project Euler 85, Python and J
I understand that boxed index lists can be used to index
multi-dimens
54
This stays in 2 dimensions.
Linda
-Original Message-
From: [email protected]
[mailto:[email protected]] On Behalf Of Raul Miller
Sent: Saturday, October 11, 2014 6:10 PM
To: Programming forum
Subject: Re: [Jprogramming] Project Euler 85, Python and J
I
software.com
[mailto:[email protected]] On Behalf Of Raul Miller
Sent: Saturday, October 11, 2014 6:10 PM
To: Programming forum
Subject: Re: [Jprogramming] Project Euler 85, Python and J
I understand that boxed index lists can be used to index multi-dimensioned
arrays. And th
gt; > >Right "prong" is the aforementioned element indices.
> > >
> > >Left "prong" is the shape of the original array/matrix.
> > >
> > >middle "prong" is the antibase of the right prong w.r.t. the left.
> > &
>middle "prong" is the antibase of the right prong w.r.t. the left.
> >
> > This seems to work for matrices of any size or dimension.
> >
> > Is this the standard way to index multidimensional arrays?
> >
> >
> >
> > > From: [email protected]
&g
>
>middle "prong" is the antibase of the right prong w.r.t. the left.
>
> This seems to work for matrices of any size or dimension.
>
> Is this the standard way to index multidimensional arrays?
>
>
>
> > From: [email protected]
> > To: programm...@
sides 31 x 63 is 36.
I think the verb "all" is under-counting, as 2 all 3 should be 18, not 16.
> From: [email protected]
> To: [email protected]
> Date: Sat, 11 Oct 2014 02:28:18 -0400
> Subject: Re: [Jprogramming] Project Euler 85, Python and J
>
> I
[email protected]
[mailto:[email protected]] On Behalf Of Linda Alvord
Sent: Tuesday, October 07, 2014 4:34 AM
To: [email protected]
Subject: Re: [Jprogramming] Project Euler 85, Python and J
This fits in nicely somewhere in the elementary school years! I hope that
93 by 93 is rhe
l arrays?
> From: [email protected]
> To: [email protected]
> Date: Sat, 11 Oct 2014 06:33:45 +0100
> Subject: Re: [Jprogramming] Project Euler 85, Python and J
>
> Using (2 ! >:) is clearly better than doing my double for-loop. I'm
> embarrassed I missed
dices are prime (just a random example).
In procedural python this could be quickly done with a double for-loop and a
prime test. In J this type of problem still escapes me.
> Date: Fri, 10 Oct 2014 19:35:26 -0400
> From: [email protected]
> To: [email protected]
> Subject: R
:
> What is the correct answerfor this problem?
>
> Linda
>
> -Original Message-
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Stefano
> Lanzavecchia
> Sent: Friday, October 10, 2014 11:47 AM
>
: [Jprogramming] Project Euler 85, Python and J
Actuary the use of ravel and antibase is common practice to solve
certain problems in APL and isn't considered cheating. So I wouldn't
say it's "not nice" but I would definitely go for antibase instead of
a combination of floored
-Original Message-
From: [email protected]
[mailto:[email protected]] On Behalf Of Tikkanz
Sent: Tuesday, October 07, 2014 8:20 PM
To: Programming JForum
Subject: Re: [Jprogramming] Project Euler 85, Python and J
Here is another version of countRe
Actuary the use of ravel and antibase is common practice to solve
certain problems in APL and isn't considered cheating. So I wouldn't
say it's "not nice" but I would definitely go for antibase instead of
a combination of floored-divide and modulus. As a bonus, a solution
based on antibase would sc
Hi,
A dirty trick to get the job done would be to ravel the matrix ( , ), solve
the 1d version of the problem and then get the "true" indexes with
something like (<.@%&200 , 200&|).
For example, if you needed to just find the max:
(<.@%&200 , 200&|) (i. >./) , m
where m is your matrix.
I know this
- pe85(i,j))
> if diff < bestfit:
>area = i*j
>bestfit = diff
>
> print "AREA is "+str(area)
>> From: [email protected]
>> To: [email protected]
>> Date: Tue, 7 Oct 2014 05:37:27 +0100
>> Su
Nice solution.
The original post had a question which I interpret as "How do I find the
index list of the largest number in a multidimensional array?"
($ #: (i. >./)@:,) array
($ #: (i. >./)@:,) 3 1 4 1 5 9 6
5
($ #: (i. >./)@:,) 3 3 $ 0 0 0 9 0 0 0 0 0
1 0
Henry Rich
On 10/7/20
Oleg's j solution is near the end of the comments section for PE 85.
On 10/07/2014 02:50 AM, [email protected] wrote:
Date: Tue, 7 Oct 2014 05:37:27 +0100
From: Jon Hough
To:"[email protected]"
Subject: [Jprogramming] Project Euler 85, Python a
ay, October 07, 2014 13:41
To: Programming JForum
Subject: Re: [Jprogramming] Project Euler 85, Python and J
Note that 200 x 200 is a bit of an overkill given 3x2 = 2x3
The following choses the lower triangular of a matrix of the different
sized rectangles to investigate.
getSizes=: ,@(>:/~) # [:
-Original Message-
From: [email protected]
[mailto:[email protected]] On Behalf Of Jon Hough
Sent: Tuesday, October 07, 2014 12:46 AM
To: [email protected]
Subject: Re: [Jprogramming] Project Euler 85, Python and J
Sorry, my line breaks got de
October 07, 2014 13:41
To: Programming JForum
Subject: Re: [Jprogramming] Project Euler 85, Python and J
Note that 200 x 200 is a bit of an overkill given 3x2 = 2x3
The following choses the lower triangular of a matrix of the different
sized rectangles to investigate.
getSizes=: ,@(>:/~) # [: ,/
1 2
1 2
1 2
1 2
1 2
Ben
From: [email protected]
[[email protected]] on behalf of Jon Hough
[[email protected]]
Sent: Tuesday, October 07, 2014 06:37
To: [email protected]
Subject: [Jprogramming] Project Euler 85, Py
This (2!>:) version seems more straightforward, especially if accompanied
by a comment pointing out that you're looking for the number of
combinations (*/) of all pairs of lines (2!) and the number of lines is one
more than each dimension (>:) because they delineate the boundaries of the
cells. It
Here is another version of countRects
countRects=: */@(2 ! >:)
On Wed, Oct 8, 2014 at 9:07 AM, Tikkanz wrote:
> Sorry, yes that is a leap.
> (x * (x + 1)) * 0.5 is the number of ways to choose two horizontal lines
> to make 2 sides of the rectangle.
> (y * (y + 1)) * 0.5 is the number of ways to
Sorry, yes that is a leap.
(x * (x + 1)) * 0.5 is the number of ways to choose two horizontal lines to
make 2 sides of the rectangle.
(y * (y + 1)) * 0.5 is the number of ways to choose two vertical lines to
make the other 2 sides of the rectangle
((x * (x + 1)) * 0.5) * ((y * (y + 1)) * 0.5) is th
ould be more general than the
> getSizes filter for >: i.2000
>
>4 %~ */@(, >:) 1 2000x
> 2001000
>4 %~ */@(, >:) 1 1999x
> 1999000
>
>
> - Original Message -
> From: Devon McCormick
> To: J-programming forum
> Cc:
> Sent: Tuesday,
than the getSizes
filter for >: i.2000
4 %~ */@(, >:) 1 2000x
2001000
4 %~ */@(, >:) 1 1999x
1999000
- Original Message -
From: Devon McCormick
To: J-programming forum
Cc:
Sent: Tuesday, October 7, 2014 11:30 AM
Subject: Re: [Jprogramming] Project Euler 85, Python and
To answer Jon's last question, if "nr" is my matrix of results from
"countRects", then this gives me the index of the lowest (closest to 2e6)
in the raveled matrix:
(3 : '(] i. <./) ,y') 2e6(-|)nr
499
If we think of the indexes of a table as being a base ($table) number, we
can decode the vecto
Hi -
"countRects" seems like a bit of a leap. I think I understand "4 %~"
because you're overcounting by 4 rotations, but I don't comprehend the
magic behind "*/@(,>:)".
I see that "(,>:)" concatenates the shape to its increment, e.g. 2 3 3 4
for the input 2 3, but what's the rationale behind th
Note that 200 x 200 is a bit of an overkill given 3x2 = 2x3
The following choses the lower triangular of a matrix of the different
sized rectangles to investigate.
getSizes=: ,@(>:/~) # [: ,/ ,"0/~
getSizes >: i. 5
Given the sides of a rectangle you can count the number of rectangles as
follows:
c
ct 2014 05:37:27 +0100
> Subject: [Jprogramming] Project Euler 85, Python and J
>
> Project Euler 85: https://projecteuler.net/problem=85
> This problem is not really conceptually hard, but I am struggling with a J
> solution.I have solved it in Python:
> =
Project Euler 85: https://projecteuler.net/problem=85
This problem is not really conceptually hard, but I am struggling with a J
solution.I have solved it in Python:
=
def pe85(larg, rarg): count = 0 llist = range(1, larg+1)rlist =
range
rogramming] Project Euler Problem 8
for n, there is the simpler:
n =. ; cutLF wd 'clippaste'
after selecting and copying from project euler site.
- Original Message -
From: Linda Alvord
To: [email protected]
Cc:
Sent: Friday, July 4, 2014 11:14:53 PM
Subject: Re: [J
for n, there is the simpler:
n =. ; cutLF wd 'clippaste'
after selecting and copying from project euler site.
- Original Message -
From: Linda Alvord
To: [email protected]
Cc:
Sent: Friday, July 4, 2014 11:14:53 PM
Subject: Re: [Jprogramming] Project Euler Proble
Subject: Re: [Jprogramming] Project Euler Problem 8
Here's my try at this.
A=:'73167176531330624919225119674426574742355349194934'
B=:'96983520312774506326239578318016984801869478851843'
C=:'85861560789112949495459501
+/i.996){y'
f n
40824
Linda
-----Original Message-
From: [email protected]
[mailto:[email protected]] On Behalf Of mvillarino
Sent: Friday, July 04, 2014 1:46 AM
To: [email protected]
Subject: Re: [Jprogramming] Project Euler Problem 8
Than
Thanks a lots!, Now i'll study this over the next week !
> >./ 13 */@:". \ n
>
>
>(#~ ( 13 = '0' i.~ ])"1) 13,\ 40{. n
> turns out I was wrong and it is faster to filter out the 0s!
Same happens for problem nr 4, that of the maximum palindrome with
five or six figures recently discussed.
timespacex ' >./ ([: */ "."0)"1 (#~ ( 13 = ''0'' i.~ ])"1) 13,\ n'
0.00241984 44672
- Original Message -
From: 'Pascal Jasmin' via Programming
To: "[email protected]"
Cc:
Sent: Thursday, July 3, 2014 7:3
1) 13,\ n'
0.00065632 33792
turns out I was wrong and it is faster to filter out the 0s!
- Original Message -
From: mvillarino
To: [email protected]
Cc:
Sent: Thursday, July 3, 2014 6:18:10 PM
Subject: [Jprogramming] Project Euler Problem 8
I came to this solution, which happ
I came to this solution, which happens to be a transliteration of the
problem's formulation:
>./ */"1 ".items"1(13,\number)
where «numero» is the string with the number's digits (one thousand).
Please note I'm no programmer, and I'm learning a little J with no
other intent than just for curiosity.
the mobius function. Your method does seem to be much more elegant
(and faster).
Date: Sat, 21 Jun 2014 19:03:02 +0100
From: [email protected]
To: [email protected]
Subject: Re: [Jprogramming] Project Euler 73
OK, Jon.
Ihad been fiddling with the mu function; my previous so
I see,
you're using the mobius function. Your method does seem to be much more elegant
(and faster).
> Date: Sat, 21 Jun 2014 19:03:02 +0100
> From: [email protected]
> To: [email protected]
> Subject: Re: [Jprogramming] Project Euler 73
>
> OK, Jon.
f
h =. +/@:g
h >: i.12000
gives the answer:
7295372
This seems to be the same as others have. But since Project Euler is no more,
we'll never know if it is correct.Note: I haven't tested the speed but it seems
to be a bit clunky, taking about 3~4 seconds on my PC.
Regards,Jon
Date:
ds,Jon
> Date: Tue, 17 Jun 2014 19:35:04 +0100
> From: [email protected]
> To: [email protected]
> Subject: Re: [Jprogramming] Project Euler 73
>
> In private correspondence, "Pascal Jasmin" suggests I air these
> functions in the forum.
>
In private correspondence, "Pascal Jasmin" suggests I air these
functions in the forum.
Please note that the following is a spoiler for an Euler Project
solution method, so I'm placing listings some way down.
On my Samsung ultranotebook, that's not ultrafast: (sorry for any
line-wraps)
N
contrast, my "brute force" method is less than 12k "loops" (/), a single
data parsing pass, and uses J's fast +/ +./ and i. functions to quickly get
totals at high rank.
- Original Message -
From: David Lambert
To: programming
Cc:
Sent: Monday, June 16, 2014
n 06/16/2014 02:25 PM, [email protected] wrote:
Date: Mon, 16 Jun 2014 10:49:26 -0700
From: "'Pascal Jasmin' via Programming"
To:"[email protected]"
Subject: Re: [Jprogramming] Project Euler 73
Message-ID:
<1402940966.65707.ya
0.5 e73A / 2,~ 4+ i.11997'
0.869262 434688
- Original Message -
From: 'Pascal Jasmin' via Programming
To: "[email protected]"
Cc:
Sent: Monday, June 16, 2014 1:49:26 PM
Subject: Re: [Jprogramming] Project Euler 73
an explicit version for clarity
x +./ (>. x % 3) rangei (<. x % 2)''/ 2,~ 4+
i.11997'
0.43 446592
- Original Message -
From: Skip Cave
To: "[email protected]"
Cc:
Sent: Monday, June 16, 2014 12:14:20 PM
Subject: Re: [Jprogramming] Project Euler 73
It doesn't look lik
I don't remember if and how I solved this - and the project Euler site is
down - but it seems like a generative approach might be the way to go: for
each numerator "n", consider only denominators between 2n and 3n.
On Mon, Jun 16, 2014 at 12:14 PM, Skip Cave wrote:
> It doesn't look like my app
It doesn't look like my approach of making a list of floating point
fractions between 1/2 and 1/3, converting to rationals, and eliminating
large numerators & denominators, is very practical. Even using a million
decimal fractions in evenly spaced steps between 1/2 and 1/3, that still
doesn't produ
plenty adequate here"
I'm curious. How is there a trivial method to solve this problem...
Date: Sun, 15 Jun 2014 18:20:24 -0500
From: [email protected]
To: [email protected]
Subject: Re: [Jprogramming] Project Euler 73
Ooops, I meant
+/12001>".(": f) rplc
Raul said, "Also, a trivial approach seems plenty adequate here"
I'm curious. How is there a trivial method to solve this problem...
> Date: Sun, 15 Jun 2014 18:20:24 -0500
> From: [email protected]
> To: [email protected]
> Subject: Re: [Jprogramming]
Raul, you're right. I need a finer step between all the fractions, as my
list is missing a few fractions.
Skip
Skip Cave
Cave Consulting LLC
On Sun, Jun 15, 2014 at 7:51 PM, Raul Miller wrote:
> This doesn't seem to represent any of these values:
>4993r11983 4988r11971 4983r11959 4978r119
This doesn't seem to represent any of these values:
4993r11983 4988r11971 4983r11959 4978r11947
FYI,
--
Raul
On Sun, Jun 15, 2014 at 8:15 PM, Skip Cave wrote:
> Well,
>
> load 'strings'
>f =. x:1%2+1%~i.10001 NB. Generate equal-spaced floating fractions
> between 1/3 and 1/2
>
Well,
load 'strings'
f =. x:1%2+1%~i.10001 NB. Generate equal-spaced floating fractions
between 1/3 and 1/2
k =. 12001>".(": f) rplc ' ';',';'r';',' NB. Find all numerators and
denominators less than 12001
counts all numerators and denominators below 12000 as separate entities.
Unfort
I generally avoid project euler, because I do not like working under its
constraint on disclosure. So I'm pleased when something leaks out that I
can play with. But I also try to live within the implied spirit of the
contest, so I'm not going to release my code.
Still: a quick calculation suggests
Ooops, I meant
+/12001>".(": f) rplc ' ';',';'r';','
I always have trouble with greater-thans...
Skip
Skip Cave
Cave Consulting LLC
On Sun, Jun 15, 2014 at 4:36 PM, Skip Cave wrote:
> Would this work for Euler 73?
>
>load 'strings'
>f =. x:1%2+1%~i.10001
> +/12001<".(": f) rplc
On 15/06/2014 16:59, Jon Hough wrote:
>Another Project Euler... (apologies)
>#73http://projecteuler.net/problem=73
>I found this one more tricky than it first seems.
>My attempt fails.
>My reasoning of solution. Trying to find all reduced fractions with
denominator and numerator in range 1... 12
1 - 100 of 147 matches
Mail list logo