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:programming-boun...@forums.jsoftware.com] 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
s of i. y
> > >idxClosest=: 4 : '(i. <./)@(x |@:- ])y'"(0 2) NB. Index of mat y
> to
> > > value x
> > >({~ *2e6*&idxClosest@:(countRects"1)) getSizes >: i.200NB.
> > Closest
> > > to 2e6
> > > 77 36
> &
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: programm...@jsoftware.com
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. <./)@(
ing-boun...@forums.jsoftware.com] on behalf of Jon Hough
[jgho...@outlook.com]
Sent: Saturday, October 11, 2014 07:43
To: programm...@jsoftware.com
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
boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] 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: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] 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:programming-boun...@forums.jsoftware.com] 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: jgho...@outlook.com
&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: jgho...@outlook.com
> > 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: lindaalv...@verizon.net
> To: programm...@jsoftware.com
> Date: Sat, 11 Oct 2014 02:28:18 -0400
> Subject: Re: [Jprogramming] Project Euler 85, Python and J
>
> I
...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Linda Alvord
Sent: Tuesday, October 07, 2014 4:34 AM
To: programm...@jsoftware.com
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: jgho...@outlook.com
> To: programm...@jsoftware.com
> 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
programming-boun...@forums.jsoftware.com
> > [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Stefano
> > Lanzavecchia
> > Sent: Friday, October 10, 2014 11:47 AM
> > To: programm...@jsoftware.com
> > Subject: Re: [Jprogramming] Project Euler 85, Python and J
>
:
> What is the correct answerfor this problem?
>
> Linda
>
> -Original Message-
> From: programming-boun...@forums.jsoftware.com
> [mailto:programming-boun...@forums.jsoftware.com] 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: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] 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: jgho...@outlook.com
>> To: programm...@jsoftware.com
>> 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, programming-requ...@forums.jsoftware.com wrote:
Date: Tue, 7 Oct 2014 05:37:27 +0100
From: Jon Hough
To:"programm...@jsoftware.com"
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: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Jon Hough
Sent: Tuesday, October 07, 2014 12:46 AM
To: programm...@jsoftware.com
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: programming-boun...@forums.jsoftware.com
[programming-boun...@forums.jsoftware.com] on behalf of Jon Hough
[jgho...@outlook.com]
Sent: Tuesday, October 07, 2014 06:37
To: programm...@jsoftware.com
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
41 matches
Mail list logo