Re: [Jprogramming] Project Euler 85, Python and J

2014-10-16 Thread lindaalvord
[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 convenient

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-16 Thread lindaalvord
[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 convenient

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-14 Thread Mike Day
ff 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

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-14 Thread Raul Miller
...@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 convenient abstraction

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-14 Thread Mike Day
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../)

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-13 Thread Don Kelly
: 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. ./)@(x |@:- ])y'(0 2) NB. Index of mat y to value x

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-13 Thread Raul Miller
2014 19:35:26 -0400 From: devon...@gmail.com 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

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-13 Thread Tikkanz
: Fri, 10 Oct 2014 19:35:26 -0400 From: devon...@gmail.com 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

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-12 Thread Linda Alvord
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 convenient abstraction. However, I have been dealing with very large

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-12 Thread Mike Day
] 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 convenient abstraction. However, I have been dealing

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-12 Thread Mike Day
: 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 convenient abstraction. However, I have been dealing with very large datasets recently, and boxed data on the critical path, at least for some

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-12 Thread Ben Gorte - CITG
...@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 dimensions. I'm

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-11 Thread Linda Alvord
...@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

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-11 Thread Jon Hough
of 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 have not followed the Python

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-11 Thread Raul Miller
to work for matrices of any size or dimension. Is this the standard way to index multidimensional 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

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-11 Thread Devon McCormick
...@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 that. The real meat of my confusion with multidimensional arrays

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-11 Thread Raul Miller
. Is this the standard way to index multidimensional 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

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Ben Gorte - CITG
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, Python and J Project Euler 85

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Ben Gorte - CITG
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=: ,@(:/~) # [: ,/ ,0/~ getSizes : i. 5 Given

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Linda Alvord
AM To: programm...@jsoftware.com Subject: Re: [Jprogramming] Project Euler 85, Python and J Sorry, my line breaks got deleted in the email. Her is my Python code: def pe85(larg, rarg): count = 0 llist = range(1, larg+1) rlist = range(1, rarg+1) for l in llist

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread David Lambert
] Project Euler 85, Python and J Message-ID:dub126-w86e5bcc6a9b2e4bcd852c1ac...@phx.gbl Content-Type: text/plain; charset=iso-8859-1 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

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Henry Rich
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/2014

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Dan Bron
To: programm...@jsoftware.com Date: Tue, 7 Oct 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

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Sebastiano Tronto
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 isn't a

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Stefano Lanzavecchia
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

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Linda Alvord
PM To: Programming JForum Subject: Re: [Jprogramming] Project Euler 85, Python and J Here is another version of countRects countRects=: */@(2 ! :) On Wed, Oct 8, 2014 at 9:07 AM, Tikkanz tikk...@gmail.com wrote: Sorry, yes that is a leap. (x * (x + 1)) * 0.5 is the number of ways to choose two

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Linda Alvord
: [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-divide and modulus. As a bonus

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Devon McCormick
? 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 To: programm...@jsoftware.com Subject: Re: [Jprogramming] Project Euler 85, Python

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Jon Hough
). 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: devon...@gmail.com To: programm...@jsoftware.com Subject: Re: [Jprogramming] Project Euler 85, Python and J

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-10 Thread Jon Hough
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 that. The real meat of my confusion with multidimensional arrays is in not just

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-08 Thread Devon McCormick
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

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-07 Thread Tikkanz
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:

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-07 Thread Devon McCormick
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 this?

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-07 Thread Devon McCormick
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 vector

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-07 Thread 'Pascal Jasmin' via Programming
filter for : i.2000 4 %~ */@(, :) 1 2000x 2001000 4 %~ */@(, :) 1 1999x 1999000 - Original Message - From: Devon McCormick devon...@gmail.com To: J-programming forum programm...@jsoftware.com Cc: Sent: Tuesday, October 7, 2014 11:30 AM Subject: Re: [Jprogramming] Project Euler 85

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-07 Thread Devon McCormick
%~ */@(, :) 1 1999x 1999000 - Original Message - From: Devon McCormick devon...@gmail.com To: J-programming forum programm...@jsoftware.com Cc: Sent: Tuesday, October 7, 2014 11:30 AM Subject: Re: [Jprogramming] Project Euler 85, Python and J Hi - countRects seems like a bit

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-07 Thread Tikkanz
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

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-07 Thread Tikkanz
Here is another version of countRects countRects=: */@(2 ! :) On Wed, Oct 8, 2014 at 9:07 AM, Tikkanz tikk...@gmail.com 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

[Jprogramming] Project Euler 85, Python and J

2014-10-06 Thread Jon Hough
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 =

Re: [Jprogramming] Project Euler 85, Python and J

2014-10-06 Thread Jon Hough
: [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: = def pe85(larg, rarg): count = 0 llist