Here's the parsing routine I used for day 1: parse=: {{ +/@(__&".;._2);._2 (y,LF) rplc LF2;LF,'/'}}
Its y argument would be the raw text of the input.txt provided for day 1. I hope this makes sense, -- Raul On Fri, Dec 2, 2022 at 11:36 AM Jaume <greenni...@gmail.com> wrote: > > Hello all > > I've been trying to dabble in J for quite some time, but I still haven't > got the hang of it, so I'm trying (not for the first time) to go in deep > trying to solve each day. > > Alas sometimes it feels like hitting my head against the wall, and so I > come to you with what I tried and what I lack to end the problem. Let's > start. > > On day 1 we have an heterogeneous array, and we have to get the elf who > carries the most calories. > > Using the example I can solve it for both parts of the day, using a boxed > array. > > in=: 1000 2000 3000;4000;5000 6000;7000 8000 9000;10000 > > {. \:~>+/ each in > > 24000 > > +/ 3 {. \:~>+/ each in > > 45000 > > I can read the data from a file and I can also format it like in the > instruction above > > p =: 1!:1<'test.input' > > p rplc (LF,LF);';';LF;' ' > > 1000 2000 3000;4000;5000 6000;7000 8000 9000;10000 > > But how do I go from one representation to the other? Or if there's another > way to do this transformation I'm all eyes. > > I know that that is a string, and I know that numbers are different and I > know of ". to transform to numbers. I don't know how to partition the input > on something. > > 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