My solution,

in2  =. > ". leaf 2 5 8 11 {"1 ;:"1 ('-';'_') rplc~"1 a =. > cutLF wdclippaste 
''

rperm =: [: >@:(4 : '  map =. x ~: y [ o =. x ,"1 y  for_j. i. {: $ map do. o 
=. o , (>:j) ({. , x , }.)"1 y #~ j{"1 map  end. ~. o '&.>/) (a: -.~ [: , 
<"0@}./.~) , <@:({~ ([: (i.@! A. i.) #))@~.

NB.http://code.jsoftware.com/wiki/Essays/AllPartitions

Parts =: (1: + - ;@(<@$:"0 >:@i.) ])`(< }. ] ,:@# 1:)@.<: \

>./ in2 */@:(0:^:(_1 = *)"0)@(+/)@(*("_ 1))  ; rperm each <"1 ]  4 Parts~ 100

part 2:

(>./ ) in2 */@:(0:^:(_1 = *)("0))@(+/)@(*("_ 1)) 2 9 1 8  (] #~ 500 = +/@:*"1)  
; rperm each <"1 ]  4 Parts~ 100


As to your question, I've been on the leaderboard a few times, and have excuses 
for either missing it, or not being higher such as typing disabilities (too 
many typos in the dark), failing to read or think by trying to go too fast 
(submit first, think 2nd).  I had difficulty with the json one.

I don't get everything on the first try.  Even parsing.  I used to know regex 
more, but because J is more powerful, I use that instead.  But I'm sure there 
are people who can parse simpler things with regex on the first try faster than 
I can with J.

Parentheses problems, IMO, are a big slowdown and typo challenging.  The fact 
that I choose to solve everything in console rather than a file (except for 
library toolkit) is a slowdown, as editing involves more cursor movement than 
file editing.  Other languages have better editor support, and me using 1970s 
technology doesn't help.

The main reason I choose to work this way is that it avoids the type of bug 
where I did or changed 10 things, and then when running, I need to find which 
of the 10 things was wrong, which can sometimes stump me for a long time.  I 
prefer always knowing what to try next, as opposed to the feeling of being lost 
why stuff isn't working.

For this challenge, if I was working imperatively, 4 nested loops would be 
fairly quick to type out correctly, and use less memory.  editor magic helps 
too.


Some problems I had with this challenge was finding a better partition function 
than the terrible one I had in my library.  (Slow and memory wasteful with 
problems for 4 part 100 that made my system crawl)

The reshaping step in functional array approaches usually needs a couple of 
attempts.  Its much cleaner to process afterwards, but in terms of speed, 
editing an interloop does not have these issues.  


The right rank application to data is also a slowdown.

For this challenge, If I had the above Partition function, I would still have 
made 2 initial mistakes:  used a wrong permutation function (
,/ 0 1 2 3 |. "0 2"1) which doesn't get all of them, and took a few attempts to 
get the rank right.  Missed the (0:^:(_1 = *)("0)) transformation.


Pretty sure I would have easily made the 30 minute cutoff though as the crazy 
workarounds I used still came in under 1 hour.

I don't think I can personally come up with the 5-10 minute times of the perl 
editor guys though.

Usually though the additional time for doing the part b after part a has an 
instant/5-10 second edit of the code though.

________________________________
From: Geoff Canyon <[email protected]>
To: [email protected] 
Sent: Tuesday, December 15, 2015 9:30 AM
Subject: Re: [Jprogramming] advent 15


​I'm curious how fast J is to write for someone who knows what they're
doing?

In AdventOfCode only the first 100 submissions make the leaderboard, so
speed is a premium. I dabble in J, but I'm *far* more comfortable in
LiveCode, and that's what I use for AdventOfCode, although I sometimes go
back and re-solve in J later. ​

So I'm just wondering: J is remarkably powerful and compact, but how fast
is it to code once you are experienced?



----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to