[Jprogramming] Project Euler Problems Plea

2019-07-14 Thread 'Mike Day' via Programming
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

Re: [Jprogramming] Project Euler

2017-03-15 Thread Don Guinn
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

Re: [Jprogramming] Project Euler

2017-03-15 Thread 'Mike Day' via Programming
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 >>> --

Re: [Jprogramming] Project Euler

2017-03-15 Thread Don Guinn
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

Re: [Jprogramming] Project Euler

2017-03-15 Thread Don Guinn
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. >>> >

Re: [Jprogramming] Project Euler

2017-03-15 Thread 'Mike Day' via Programming
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

Re: [Jprogramming] Project Euler

2017-03-14 Thread chris burke
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

Re: [Jprogramming] Project Euler

2017-03-14 Thread 'Jon Hough' via Programming
+ 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

Re: [Jprogramming] Project Euler

2017-03-14 Thread 'Jon Hough' via Programming
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"

Re: [Jprogramming] Project Euler

2017-03-14 Thread Don Guinn
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 >

Re: [Jprogramming] Project Euler

2017-03-14 Thread 'Jon Hough' via Programming
, 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

[Jprogramming] Project Euler

2017-03-14 Thread Don Guinn
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

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread Louis de Forcrand
(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

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread 'Pascal Jasmin' via Programming
;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

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread David Lambert
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 >

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread Geoff Canyon
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. --

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread Raul Miller
): 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

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread Martin Kreuzer
(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 -

Re: [Jprogramming] Project Euler 1

2016-05-06 Thread Martin Kreuzer
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

Re: [Jprogramming] Project Euler 1

2016-05-05 Thread 'Pascal Jasmin' via Programming
> 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

Re: [Jprogramming] Project Euler 1

2016-05-05 Thread Raul Miller
+./ .= 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

Re: [Jprogramming] Project Euler 1

2016-05-05 Thread Don Guinn
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

Re: [Jprogramming] Project Euler 1

2016-05-05 Thread Geoff Canyon
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

Re: [Jprogramming] Project Euler 1

2016-05-05 Thread Raul Miller
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

Re: [Jprogramming] Project Euler 1

2016-05-05 Thread Raul Miller
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

Re: [Jprogramming] Project Euler 1

2016-05-05 Thread Mike Day
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!>

Re: [Jprogramming] Project Euler 1

2016-05-05 Thread Raul Miller
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

Re: [Jprogramming] Project Euler 1

2016-05-05 Thread Mike Day
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.

Re: [Jprogramming] Project Euler 1

2016-05-04 Thread 'Pascal Jasmin' via Programming
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

Re: [Jprogramming] Project Euler 1

2016-05-04 Thread Raul Miller
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

Re: [Jprogramming] Project Euler 1

2016-05-04 Thread Thomas McGuire
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

[Jprogramming] Project Euler 1

2016-05-04 Thread Geoff Canyon
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

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

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

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

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

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-14 Thread Raul Miller
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 >&

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

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

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

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

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

2014-10-13 Thread Raul Miller
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 >

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

2014-10-13 Thread Don Kelly
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. <./)@(

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

2014-10-12 Thread Ben Gorte - CITG
[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

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

2014-10-12 Thread Mike Day
[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

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

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

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

2014-10-12 Thread Linda Alvord
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

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

2014-10-11 Thread Raul Miller
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. > > &

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

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

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

2014-10-11 Thread Raul Miller
> >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...@

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

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

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

2014-10-10 Thread Linda Alvord
[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

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

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

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

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

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

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

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

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

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

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 sc

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

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

2014-10-10 Thread Dan Bron
- 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

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/20

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

2014-10-10 Thread David Lambert
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

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

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

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

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

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

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

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

2014-10-10 Thread Ben Gorte - CITG
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

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

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 th

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

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

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

2014-10-07 Thread 'Pascal Jasmin' via Programming
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

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 vecto

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 th

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: c

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

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

[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 = range

Re: [Jprogramming] Project Euler Problem 8

2014-07-05 Thread Linda Alvord
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

Re: [Jprogramming] Project Euler Problem 8

2014-07-04 Thread 'Pascal Jasmin' via Programming
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

Re: [Jprogramming] Project Euler Problem 8

2014-07-04 Thread Linda Alvord
Subject: Re: [Jprogramming] Project Euler Problem 8 Here's my try at this. A=:'73167176531330624919225119674426574742355349194934' B=:'96983520312774506326239578318016984801869478851843' C=:'85861560789112949495459501

Re: [Jprogramming] Project Euler Problem 8

2014-07-04 Thread Linda Alvord
+/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

Re: [Jprogramming] Project Euler Problem 8

2014-07-03 Thread mvillarino
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.

Re: [Jprogramming] Project Euler Problem 8

2014-07-03 Thread 'Pascal Jasmin' via Programming
   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

Re: [Jprogramming] Project Euler Problem 8

2014-07-03 Thread 'Pascal Jasmin' via Programming
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

[Jprogramming] Project Euler Problem 8

2014-07-03 Thread mvillarino
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.

Re: [Jprogramming] Project Euler 73

2014-06-22 Thread Mike Day
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

Re: [Jprogramming] Project Euler 73

2014-06-22 Thread Jon Hough
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.

Re: [Jprogramming] Project Euler 73

2014-06-21 Thread Mike Day
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:

Re: [Jprogramming] Project Euler 73

2014-06-21 Thread Jon Hough
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. >

Re: [Jprogramming] Project Euler 73

2014-06-17 Thread Mike Day
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

Re: [Jprogramming] Project Euler 73

2014-06-16 Thread 'Pascal Jasmin' via Programming
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

Re: [Jprogramming] Project Euler 73

2014-06-16 Thread David Lambert
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

Re: [Jprogramming] Project Euler 73

2014-06-16 Thread 'Pascal Jasmin' via Programming
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  

Re: [Jprogramming] Project Euler 73

2014-06-16 Thread 'Pascal Jasmin' via Programming
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

Re: [Jprogramming] Project Euler 73

2014-06-16 Thread Devon McCormick
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

Re: [Jprogramming] Project Euler 73

2014-06-16 Thread Skip Cave
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

Re: [Jprogramming] Project Euler 73

2014-06-16 Thread Mike Day
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

Re: [Jprogramming] Project Euler 73

2014-06-16 Thread Jon Hough
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]

Re: [Jprogramming] Project Euler 73

2014-06-15 Thread Skip Cave
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

Re: [Jprogramming] Project Euler 73

2014-06-15 Thread Raul Miller
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 >

Re: [Jprogramming] Project Euler 73

2014-06-15 Thread Skip Cave
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

Re: [Jprogramming] Project Euler 73

2014-06-15 Thread Raul Miller
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

Re: [Jprogramming] Project Euler 73

2014-06-15 Thread Skip Cave
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

Re: [Jprogramming] Project Euler 73

2014-06-15 Thread David Lambert
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   2   >