Nice solution, 3D coordinates are more direct (much less messy) than axial coordinates.
On Sun, Dec 17, 2017 at 2:57 PM, Henry Rich <[email protected]> wrote: > I haven't been following this thread but has gone on so long that I > thought I would post a solution: > > > NB. Input translation to N/SE/SW form > > 'n s ne se nw sw' =: _3 ,:\ 1 0 0 _1 0 0 0 0 _1 0 1 0 0 _1 0 0 0 1 > > NB. Apply transformations. We want the one transformtation that converts > the most move-pairs > > NB. to single moves. The second-largest value will be the number of pairs > we can convert > > xform =: (- 1 { /:~)"1 > > NB. Get input > > input =: ". wd 'clippaste' > > > +/ | xform +/ input NB. part 1 > > >./ +/"1 | xform +/\ input NB. part 2 > > > Henry Rich > > > > > > On 12/17/2017 2:23 PM, Brian Schott wrote: > >> Raul, >> >> Right, I remember now that you said that earlier >> in this thread. Obviously, I did not understand >> it then. >> >> Thanks for your patience and great help, >> >> On Sun, Dec 17, 2017 at 2:06 PM, Raul Miller <[email protected]> >> wrote: >> >> They are locations that are unique. And they can be converted into >>> either number of steps to that location or into a sequence of steps to >>> reach that location: >>> >>> nsteps=: +/@:|"1 >>> >>> path=:3 :0 >>> r=.'' >>> while. 0<+/|y do. >>> pick=. (i. <./) +/"1|dss -~"1/ y >>> y=.y-pick{dss >>> r=.r,pick{nms >>> end. >>> ) >>> >>> Beware, however, that arbitrary sequences of three integers (or half >>> integers) are not necessarily valid locations (we are working with a >>> two dimensional grid here, so those three numbers cannot be completely >>> independent of each other). Here's a variation of path which catches >>> that issue: >>> >>> apath=:3 :0 >>> o=. y >>> r=.'' >>> while. (o >:&(+/@:|) y) * 0<+/|y do. >>> o=. y >>> pick=. (i. <./) +/"1|dss -~"1/ y >>> y=.y-pick{dss >>> r=.r,pick{nms >>> end. >>> assert. 0=+/|y >>> ) >>> >>> >>> >>> ---------------------------------------------------------------------- >> For information about J forums see http://www.jsoftware.com/forums.htm >> > > > > --- > This email has been checked for viruses by AVG. > http://www.avg.com > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
