I don't know about the bolded text. It could be, haven't been much active.

I can't see where the value is transmitted in your code. Mostly I don't
understand the {. move }. part.

In the end I managed it using an accumulator variable. Didn't like it much
but...

Missatge de 'robert therriault' via Programming <programm...@jsoftware.com>
del dia dl., 5 de des. 2022 a les 17:20:

> Hi Jaume,
>
> To begin, I cut and paste the data into a temp.ijs file in the jQt
> environment, so my hat is off to you for taking a purer approach.
> For the initial stacks I created ascii coded integer vectors (gets around
> the issues with character manipulation)
> For the move commands, I defined take, put and  move verbs (I used a for
> loop for the move verb as well), then took the numbers within each box and
> applied them to the appropriate verbs.
> My move verb looped through the take and put opeerations, so it looked
> like this for each boxed instruction set
>
> ({. move }.) each boxed_instruction_list
>
> Hope this helps.
>
> By the way, I did not see bolded text, so maybe rich text format is not
> available in the forums.
>
> Cheers, bob
>
>
>
> > On Dec 5, 2022, at 07:58, Jaume <greenni...@gmail.com> wrote:
> >
> > Hello again.
> >
> > I managed to solve day 3 and 4, so maybe when I clean up my solutions I
> > will ask to review them. But right now I have a problem and some
> questions
> > on the first part of day 5.
> >
> > Main things I need in bold, mainly the last one. Feel free to code review
> > this message as much or as little as you want to.
> >
> > I can read and parse both the stacks and the instructions without
> problem,
> > but I have to manually choose where to separate them.
> >
> > ]p=:1!:1<'/home/deck/projects/adventofcode/2022/d05t1.input'
> >
> > [D]
> >
> > [N] [C]
> >
> > [Z] [M] [P]
> >
> > 1 2 3
> >
> >
> > move 1 from 2 to 1
> >
> > move 3 from 1 to 3
> >
> > move 2 from 2 to 1
> >
> > move 1 from 1 to 2
> >
> >
> > ]lines=.|:>4{.cutopen p
> >
> > [[
> >
> > NZ1
> >
> > ]]
> >
> > [[[
> >
> > DCM2
> >
> > ]]]
> >
> > [
> >
> > P3
> >
> > ]
> >
> > ]textstacks=:(4,:1)<;.3 }.lines
> >
> > ┌────┬────┬────┐
> >
> > │ NZ1│DCM2│ P3│
> >
> > └────┴────┴────┘
> >
> > ]wo=:}:each dltb each ,each textstacks
> >
> > ┌──┬───┬─┐
> >
> > │NZ│DCM│P│
> >
> > └──┴───┴─┘
> >
> > ]pc=.cutopen toJ p
> >
> >
> ┌───────────┬───────────┬───────────┬───────────┬──────────────────┬──────────────────┬──────────────────┬──────────────────┐
> >
> > │ [D] │[N] [C] │[Z] [M] [P]│ 1 2 3 │move 1 from 2 to 1│move 3 from 1 to
> > 3│move 2 from 2 to 1│move 1 from 1 to 2│
> >
> >
> └───────────┴───────────┴───────────┴───────────┴──────────────────┴──────────────────┴──────────────────┴──────────────────┘
> >
> > ins=: [: ". 'movefrt' -.~ ]
> >
> > ]moves =: ins each 4}. pc
> >
> > ┌─────┬─────┬─────┬─────┐
> >
> > │1 2 1│3 1 3│2 2 1│1 1 2│
> >
> > └─────┴─────┴─────┴─────┘
> >
> > So I can separate the data, but I don't know how to find the line where
> to
> > separate them. I tried some things but to no avail. Some variations like
> > this one.
> >
> >   'm' i.&1@: sta pc
> > 1
> >
> >
> > *So finding the first box that starts with 'm', or the first that is only
> > numbers would help. How could I find this kind of things?*
> >
> > Now onto the hard part, how to iterate through the whole array of moves.
> >
> > I can process the moves like this:
> > move=: 4 : 0
> >
> > from=:(1{y)-1
> >
> > to=:(2{y)-1
> >
> > times=:0{y
> >
> > m2=:x
> >
> > for. i.times do.
> >
> > m1=:(<(({.>from{m2),>to{m2))to}m2
> >
> > m2=:(<}.>from{m1)from}m1
> >
> > end.
> >
> > m2
> >
> > )
> >
> > wo move 1 1 2
> >
> > ┌─┬────┬─┐
> >
> > │Z│NDCM│P│
> >
> > └─┴────┴─┘
> >
> > wo move 1 2 1
> >
> > ┌───┬──┬─┐
> >
> > │DNZ│CM│P│
> >
> > └───┴──┴─┘
> >
> > From here *I would like to change the for. but I don't trust myself to do
> > it well using the power conjunction*. And it brings me up to the last
> part
> > that I have problems with, applying this to the whole array of moves.
> >
> > I tried the \. \ /\. and /\ constructs, but none have worked for me.
> >
> >   1 (ww&move@>)\moves
> > ┌────┬────┬────┐
> > │DNZ │CM  │P   │
> > └────┴────┴────┘
> >
> > ┌────┬────┬────┐
> > │    │DCM │ ZNP│
> > └────┴────┴────┘
> >
> > ┌────┬────┬────┐
> > │CDNZ│M   │P   │
> > └────┴────┴────┘
> >
> > ┌────┬────┬────┐
> > │Z   │NDCM│P   │
> > └────┴────┴────┘
> >
> >   1 (ww&move@>)/\moves
> > ┌─────┬─────┬─────┬─────┐
> > │1 2 1│3 1 3│2 2 1│1 1 2│
> > └─────┴─────┴─────┴─────┘
> >
> > And some more variations. *How do I execute the same function, with one
> > parameter being the result from the previous computation (except on the
> 1st
> > step)?*
> >
> > Thanks in advance.
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>


-- 
The fact that an opinion has been widely held is no evidence whatever that
it is not utterly absurd. -- Bertrand Russell
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to