P.S. I was going to mention, but I forgot: email managed to strip trailing spaces from your message. This caused an error in the phrase 1 5 9&{;._2 top
One workaround here is to insert trailing spaces so that that phrase evaluates. Another approach though would be to replace it with 1 5 9{];._2 top Perhaps better would be to replace }:1 5 9&{;._2 top with the more verbose (}: #"1~ ' '~:{:)];._2 top Thanks, -- Raul On Tue, Dec 6, 2022 at 2:47 PM Brian Schott <schott.br...@gmail.com> wrote: > > I have successfully solved Day 5 using the following looping verb `tomove` > but cannot craft a Fold version, and would like help. > > *[FYI I have included an attachment that seems to load and execute > properly, but I could NOT get the email versions to load correctly, > presumably because of some funny characters.]* > > tomove=: dyad define > while. #y do. > x=.x move {. y > y =. }.y > end. > x > ) > > > NB. The verb `move` for part 1 is very simple: > > move =: dyad define > 'n f t'=. _1 1 1*y - 0 1 1 > take =. |.n{.>f{x > left =. <n}.>f{x > put =. <take,~>t{x > (left,put) (f,t)}x > ) > > NB. the inputs are produced as follows. > > top =: 0 :0 > [D] > [N] [C] > [Z] [M] [P] > 1 2 3 > ) > > state=.deb each ;/ |:|.}:1 5 9&{;._2 top > > bottom =: 0 :0 > move 1 from 2 to 1 > move 3 from 1 to 3 > move 2 from 2 to 1 > move 1 from 1 to 2 > ) > alpha =. a. {~97+i.26 > moves =. ".-.&alpha ;._2 bottom > > NB. finally the result is produced by the next phrase > > {:every state tomove moves > > -- > (B=) <-----my sig > Brian Schott > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm