Thank you both. Unfortunately neither of your ways work for me.
ev =: (9 3$'A XA YA ZB XB YB ZC XC YC Z')&(4 8 3 1 5 9 7 2 6 { ~ i.) |spelling error | ev =: (9 3$'A XA YA ZB XB YB ZC XC YC Z')&(4 8 3 1 5 9 7 2 6 { ~ i.) | ^ No idea how to solve it. I tried the different & related verbs to no avail. parse=: ('ABC',:'XYZ') i."1 |:-.&' ';._2 input |length error | parse=:('ABC',:'XYZ') i."1|:-.&' ';._2 input I'm trying to use different input, but all give me the same error message. I tried reading it from the file, unboxing, making it 'A YB XC Z' ... without success. On a different note, I'm writing down all this, breaking down the sentences so I can understand them in the future too, making it in a literate programming style. I will add this to my solutions. You can see a work in progress here: https://github.com/JaumeGreen/adventofcode/blob/master/2022/day02/log.ijs Do you prefer if I cite you by name, nick, not at all? Thanks. Missatge de Raul Miller <rauldmil...@gmail.com> del dia dv., 2 de des. 2022 a les 20:39: > Here's a cleaned up version of how I approached that (here 'input' > held the raw text of input.txt provided by the aoc website). > > parsed=: ('ABC',:'XYZ') i."1 |:-.&' ';._2 input > part1=: {{ +/1+y+3*3|(1+y)-x }}/ > part2=: {{ +/(3*y)+4|&.<:x+y }}/ > > Note that my original implementations were a bit different. For > example, for part 1, I had > > scor=: {{ > 'op me'=. y > (1+me)+ 3*op {{ (x |. 2 0 1)i.y}}"0 me > }} > > and used > +/scor parsed > > I hope this makes sense, > > -- > Raul > > On Fri, Dec 2, 2022 at 12:40 PM Jaume <greenni...@gmail.com> wrote: > > > > Hello again > > I managed to solve it, but I don't like it much, so feel free to educate > me. > > > > Reading the file, and evaluating the result is something that looked > nice: > > > > p =. 1!:1<'day02.input' > > > > +/>ev each cutopen p > > > > xxxx > > > > +/>ev2 each cutopen p > > > > xxxx > > > > Now are the evaluating functions. I really don't like how they are done. > > I'd even prefer to create a table and search in it, but I don't know how. > > So a select. is used. > > > > > > ev=: 3 : 0 > > > > select. y > > > > case. 'A X' do. > > > > 4 > > > > case. 'A Y' do. > > > > 8 > > > > case. 'A Z' do. > > > > 3 > > > > case. 'B X' do. > > > > 1 > > > > case. 'B Y' do. > > > > 5 > > > > case. 'B Z' do. > > > > 9 > > > > case. 'C X' do. > > > > 7 > > > > case. 'C Y' do. > > > > 2 > > > > case. 'C Z' do. > > > > 6 > > > > end. > > > > ) > > > > > > And the same with different numbers for ev2. > > > > Would this be an appropriate way to approach the problem? Is there a > > "better" way? > > > > > > Thanks. > > ---------------------------------------------------------------------- > > 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