Re: [Jprogramming] adventofcode 6

2015-12-08 Thread Brian Schott
Jan-Pieter, I used my "amend" approach with your great parsing and your method was 4 times as fast and 6.3 times as space efficient as mine. FYI, my definitions are as follow. cells =: <@{.+each,@{@(<@:i."0@(>:@-~/))@] toggle =: -.@(cells@[ { ])`(cells@[)`]} on =: 1:`(cells@[)`]} off =: 0:

Re: [Jprogramming] adventofcode 6

2015-12-08 Thread Jan-Pieter Jacobs
You're welcome! The parsing does only use negative indexing though (mainly to easily get rid of the "turn", as the "toggle" cases don't have an element to get rid of ...) Actually, I had errors in the updating functions too before ... What you see is only the final result :) 2015-12-08 14:38 GMT+

Re: [Jprogramming] adventofcode 6

2015-12-08 Thread Brian Schott
Jan-Pieter, Thank you very much for your solution. Puzzling through it really helped me. I think your approach is really clever and your comments were perfect. I had trouble understanding your off, on, an toggle until I realized you were updating the whole array each time, because my (incomplete)

Re: [Jprogramming] adventofcode 6

2015-12-07 Thread Joe Bogner
3 5 7 9 { ])`(1 , 0 ". every 3 5 7 9 { ])@.('on' -: 2 >> Y)`(0 , 0 ". every 2 4 6 8 { ])@.(0 Y)"1( ],~ [: < 0:`1:@.('toggle' -: 0 >> Y))"1 ;:"1 > cutLF a =. wd 'clippaste' >> >> +/@, ( |. b) p2 reduce 1000 1000 $

Re: [Jprogramming] adventofcode 6

2015-12-07 Thread Jan-Pieter Jacobs
(2 + ]) amenD (p3@[) > > ` > >>:@] amenD (p3@[) > > ` > > (0 >. <:@]) amenD (p3@[) > > @. > > 0 X > > ) > > > > b =. (2 , 0 ". every 3 5 7 9 { ])`(1 , 0 ". every 3 5 7 9 { ])@.('on' > -: 2 Y)`(0 , 0 ".

Re: [Jprogramming] adventofcode 6

2015-12-07 Thread Joe Bogner
.('toggle' -: 0 > Y))"1 ;:"1 > cutLF a =. wd 'clippaste' > > +/@, ( |. b) p2 reduce 1000 1000 $ 0 > > slow because of boxing in reduce > > Henry's was quite fast. > > > - Original Message - > From: Ric Sherlock >

Re: [Jprogramming] adventofcode 6

2015-12-06 Thread 'Pascal Jasmin' via Programming
7;clippaste' +/@, ( |. b) p2 reduce 1000 1000 $ 0 slow because of boxing in reduce Henry's was quite fast. - Original Message - From: Ric Sherlock To: Programming JForum Sent: Sunday, December 6, 2015 10:14 PM Subject: Re: [Jprogramming] adventofcode 6 I struggled with an e

Re: [Jprogramming] adventofcode 6

2015-12-06 Thread Ric Sherlock
identify NB. whoops! returns a vector >>> 0 1 2 #~ 'turn on'&({.@E.) , 'turn off'&({.@E.) , 'toggle'&({.@E.) >>> >>> on >>> 3 : 0 >>> I=:([: < 2 6&g ; 4 8&g)@;:y >>> NB. L=:I (1:)`([)`(])}L

Re: [Jprogramming] adventofcode 6

2015-12-06 Thread Ryan Eckbo
L=:I (>:@:{)`([)`(])}L EMPTY ) off 3 : 0 I=:([: < 2 6&g ; 4 8&g)@;:y NB.I (0:)`([)`(])}L L=:I ((0>.<:)@:{)`([)`(])}L EMPTY ) toggle 3 : 0 I=:([: < (<:2 6)&g ; (<:4 8)&g)@;:y NB. L=: I (-.@:{)`([)`(])}L L=:I (2+{)`([)`(])}L EMPTY ) NB. what the heck??? Why is t

Re: [Jprogramming] adventofcode 6

2015-12-06 Thread 'Pascal Jasmin' via Programming
:4 8)&g)@;:y > NB. L=: I (-.@:{)`([)`(])}L > L=:I (2+{)`([)`(])}L > EMPTY > ) > > >NB. what the heck??? Why is this zero? > >+/, L [ on`off`toggle@.({.@identify)@,;._2(1!:1)<'/tmp/a' [ L=:1000 > 1000$0 > 0 >+/,L > 14110788

Re: [Jprogramming] adventofcode 6

2015-12-06 Thread 'Pascal Jasmin' via Programming
no guarantee that you would select only 1 item from the rhs. - Original Message - From: David Lambert To: programming Sent: Sunday, December 6, 2015 6:03 PM Subject: Re: [Jprogramming] adventofcode 6 Ryan made a mask shape 1000 1000 and applied it appropriately to a cumulative array.

Re: [Jprogramming] adventofcode 6

2015-12-06 Thread Henry Rich
((0>.<:)@:{)`([)`(])}L EMPTY ) toggle 3 : 0 I=:([: < (<:2 6)&g ; (<:4 8)&g)@;:y NB. L=: I (-.@:{)`([)`(])}L L=:I (2+{)`([)`(])}L EMPTY ) NB. what the heck??? Why is this zero? +/, L [ on`off`toggle@.({.@identify)@,;._2(1!:1)<'/tmp/a' [ L=:1000

Re: [Jprogramming] adventofcode 6

2015-12-06 Thread David Lambert
{)`([)`(])}L L=:I (2+{)`([)`(])}L EMPTY ) NB. what the heck??? Why is this zero? +/, L [ on`off`toggle@.({.@identify)@,;._2(1!:1)<'/tmp/a' [ L=:1000 1000$0 0 +/,L 14110788 Date: Mon, 07 Dec 2015 08:46:59 +1100 From: "Ryan Eckbo" To: programming Subject: Re

Re: [Jprogramming] adventofcode 6

2015-12-06 Thread 'Pascal Jasmin' via Programming
4 Y i.@>:@- 2 Y) ,.~"0 1 ( 1 Y + 3 Y i.@>:@- 1 Y))) i if. d = 1 do. c =. (1 + b{c) b} c elseif. d = 2 do. c=. ( <:^:(0 < ])"0 b{c) b} c elseif. 1 do. c =. (2 + b{c) b} c end. end. ) +/ +/ p2 b - Original Message ----- From: Ryan Eckbo To: programming Sent

Re: [Jprogramming] adventofcode 6

2015-12-06 Thread Ryan Eckbo
How do your on/off/toggle functions work? My solution also updates a global matrix, but my implementation doesn't feel good. Looking forward to seeing nicer solutions. xind=: 3 : 0&{ + [: i. >:@:(-/)@:(2 0&{) yind=: 3 : 1&{ + [: i. >:@:(-/)@:(3 1&{) mkmask=: 3 : '1 inds} 1000 1000 $ 0 [ inds=