I posted an alternate solution, a =. wdclippaste '' NB. input from clipboard
O =: 4 2 $ _1 0 0 1 1 0 0 _1 f =: 4 : 0 a =. 4 | x ({.@] + _1 1 {~ 'R' = {.@[) {: y y , a , (}. {: y) + x (".@}.@[ * O {~ ]) a ) +&|/ }. {: > f each/ (,: 0 0 0) (, <)~ |. dltb each ',' cut a f each/ (,: 0 0 0) (, <)~ |. dltb each ',' cut a NB. part 1 plot <"1 |: }."1 > f each/ (,: 0 0 0) (, <)~ |. dltb each ',' cut a NB. part 2, find intersection in plot general description, O holds direction vectors, 0 0 0 is appended to reversed list of commands, where position 0 is the orientation index into 0, and other 2 are x y positions of taxi. f/ updates orientation and x y on each iteration, where intermediate value a is new orientation. ----- Original Message ----- From: Joe Bogner <joebog...@gmail.com> To: programm...@jsoftware.com Sent: Thursday, December 1, 2016 1:43 PM Subject: Re: [Jprogramming] advent of code 2016 I added an alternate solution to problem 1, part 1 - http://code.jsoftware.com/wiki/Essays/Advent_Of_Code_2016#Imperative_Style_.28cleanup.29 If I had the time, I would think about how to reformulate it so I could use / to reduce the input to a single solution. I recall using that pattern last year On Thu, Dec 1, 2016 at 12:53 PM, Joe Bogner <joebog...@gmail.com> wrote: > I've started a wiki page for it so we don't have to go back and add > them later. Feel free to edit/add > > http://code.jsoftware.com/wiki/Essays/Advent_Of_Code_2016 > > My solution to the first problem is pretty bad (works though). I > intend to add another solution that's in a more functional style > > On Thu, Dec 1, 2016 at 11:16 AM, 'Pascal Jasmin' via Programming > <programm...@jsoftware.com> wrote: >> back again this year, >> >> >> http://adventofcode.com/2016 >> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm