Re: [Jprogramming] Questions on Advent of code Day 1

2022-12-02 Thread Raul Miller
Actually, I originally had LF,LF until someone pointed out that LF2 was in stdlib. That said, other parsing approaches for the day 1 data are perfectly viable. For example: +/|:".@;S:1 cutLF each cutpara data -- Raul On Fri, Dec 2, 2022 at 7:25 PM 'Mike Day' via Programming wrote: > > LF2

Re: [Jprogramming] Questions about Advent of Code Day 2

2022-12-02 Thread 'Mike Day' via Programming
I encoded both ABC & XYZ as 0 1 2 and used 3x3 score-tables, different ones for each part, 0 _1 _2 |."0 1 ] 3 6 0 for pt 1, 0 1 2 |."0 1 ] 3 1 2 for pt 2 There was an extra item to add in each part, corresponding to the chosen play, rock/paper/scissors, in pt 1, and the specified result, l

Re: [Jprogramming] Questions on Advent of code Day 1

2022-12-02 Thread 'Mike Day' via Programming
LF2 ... new to me! I was a bit thrown by the parsing of the trivial example being different from that for the data file; however that's likely a by-product of copy&paste on the example versus downloading the file. Anyway, I wasn't expecting LF,LF (or LF2); the usual LF cut ... missed the e

Re: [Jprogramming] Questions about Advent of Code Day 2

2022-12-02 Thread Jaume
Thank you both. That was it. Too long a day. Missatge de bill lam del dia ds., 3 de des. 2022 a les 0:11: > Perhaps you copy and paste from email to J and it contained nonbreak space > that visually identical to a normal space. > > Typing it manually may solve your problem. > > On Sat, 3 Dec 202

Re: [Jprogramming] Questions about Advent of Code Day 2

2022-12-02 Thread bill lam
Perhaps you copy and paste from email to J and it contained nonbreak space that visually identical to a normal space. Typing it manually may solve your problem. On Sat, 3 Dec 2022 at 6:47 AM Jaume wrote: > Thank you both. > > Unfortunately neither of your ways work for me. > > ev =: (9 3$'A XA

Re: [Jprogramming] Questions about Advent of Code Day 2

2022-12-02 Thread Henry Rich
Going to https://code.jsoftware.com/wiki/Vocabulary/ErrorMessages#spelling suggests that you have cut & pasted an invalid character. Henry Rich On 12/2/2022 5:47 PM, Jaume wrote: 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

Re: [Jprogramming] Questions about Advent of Code Day 2

2022-12-02 Thread Jaume
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

Re: [Jprogramming] Avoiding J crash

2022-12-02 Thread Raul Miller
Note that, depending on the resource being limited, ulimit may cause the process to crash or shut down when that resource hits the limit. -- Raul On Fri, Dec 2, 2022 at 9:54 AM David Lambert wrote: > > To avoid this situation is it possible to limit memory and cpu time on > the process? > > bas

Re: [Jprogramming] Questions on Advent of code Day 1

2022-12-02 Thread Raul Miller
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 wrote: > > Hello all > > I've been trying to da

Re: [Jprogramming] Questions about Advent of Code Day 2

2022-12-02 Thread Raul Miller
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 differ

Re: [Jprogramming] Questions about Advent of Code Day 2

2022-12-02 Thread 'Pascal Jasmin' via Programming
your select function ev can be replaced with ev =: (9 3$'A XA YA ZB XB YB ZC XC YC Z')&(4 8 3 1 5 9 7 2 6 { ~ i.) ev 'A X' 4 On Friday, December 2, 2022 at 12:40:53 p.m. EST, Jaume wrote: Hello again I managed to solve it, but I don't like it much, so feel free to educate me. Readi

[Jprogramming] Questions about Advent of Code Day 2

2022-12-02 Thread Jaume
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 +/>ev2 each cutopen p Now are the evaluating functions. I really don't li

[Jprogramming] Questions on Advent of code Day 1

2022-12-02 Thread Jaume
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 la

Re: [Jprogramming] Avoiding J crash

2022-12-02 Thread David Lambert
To avoid this situation is it possible to limit memory and cpu time on the process? bash provides ulimit, maybe DOS has similar facility.  That said, I've not gotten ulimit to work as I expect and instead increased my computer's RAM.  Then when I suspect there might be trouble I monitor the s

Re: [Jprogramming] Avoiding J crash

2022-12-02 Thread Henry Rich
Run jbreak twice to interrupt the running sentence (at the next point where it allocates memory, which is often).  A single Jbreak interrupts only at the end of a sentence. Henry Rich On 12/2/2022 6:58 AM, 'Mike Day' via Programming wrote: If .../bin/jbreak.bat doesn’t work, I use Task Manag

Re: [Jprogramming] Avoiding J crash

2022-12-02 Thread 'Mike Day' via Programming
Sorry, I didn’t spot Elijah’s reply. M Sent from my iPad > On 2 Dec 2022, at 11:58, Mike Day wrote: > > If .../bin/jbreak.bat doesn’t work, I use Task Manager to “end task”. > Forgive me if > This is blindingly obvious, but you didn’t mention it! > > Cheers, > > Mike > > > > Sent from

Re: [Jprogramming] Avoiding J crash

2022-12-02 Thread 'Mike Day' via Programming
If .../bin/jbreak.bat doesn’t work, I use Task Manager to “end task”. Forgive me if This is blindingly obvious, but you didn’t mention it! Cheers, Mike Sent from my iPad > On 2 Dec 2022, at 10:53, Richard Donovan wrote: > > Hi! > > Is there any way to avoid the situation whereby by er

Re: [Jprogramming] Avoiding J crash

2022-12-02 Thread Elijah Stone
Rebooting is a bit drastic; can you not kill j from task manager? Beyond that, break _should_ work. I can look into making it a bit more responsive for long array operations, but am curious to know what specifically has caused you trouble. On Fri, 2 Dec 2022, Richard Donovan wrote: Hi! Is

Re: [Jprogramming] Avoiding J crash

2022-12-02 Thread Ian Clark
This is a serious known issue in jios. But since you say "Windows laptop" I guess you don't mean jios. As far as jios is concerned, all I can say is: I'm working on it. On Fri, 2 Dec 2022 at 10:53, Richard Donovan wrote: > Hi! > > Is there any way to avoid the situation whereby by error I put

[Jprogramming] Avoiding J crash

2022-12-02 Thread Richard Donovan
Hi! Is there any way to avoid the situation whereby by error I put J into an infinite loop from which the only recovery is to reboot my Windows laptop? I guess that my erroneous routine is locking the CPU to such a such an extent that I can’t even get to run Jbreak. I quite often receive a re