[Jprogramming] Questions on day 15th of Advent of code 2022, optimization woes

2022-12-15 Thread Jaume
Hello all Once again with questions, now more on the performance side, mostly because it's taking too long, and giving me a wrong answer some of the time. Talking about part 2. I'll share all of the code, so if you see anything glaringly wrong please let me know. read=:{{cutopen 1!:1 filter each

Re: [Jprogramming] Questions on day 15th of Advent of code 2022, optimization woes

2022-12-15 Thread Jaume
Forget about the part not working... it lacked a 0, it had to be 4 million, not 4 hundred thousand. The part about improving it.. yeah, that could be interesting, not in a rush though. Missatge de Jaume del dia dj., 15 de des. 2022 a les 15:22: > Hello all > > Once again with questions, now mor

Re: [Jprogramming] Questions on day 15th of Advent of code 2022, optimization woes

2022-12-15 Thread Raul Miller
I also encountered performance issues on the second half of aoc 15. Ultimately, I went with a raster scan approach here: one row at a time, testing one location at a time, and one sensor at a time but skipping forward on x to the final x value within that sensor's range if that would be further al

Re: [Jprogramming] Questions on day 15th of Advent of code 2022, optimization woes

2022-12-15 Thread Raul Miller
I think your approach here, with a slight change, would be superior to the approach I used. In other words, treat the problem as defining a small set of lines bounding the scannable regions. These will all be diagonal lines, though they'll have two different orientations. The point you're looking

Re: [Jprogramming] Questions on day 15th of Advent of code 2022, optimization woes

2022-12-15 Thread Jaume
I went one way ahead. Increased the range in 1, so the point would be on an intersection, fewer points to check. Ways one could check: Go point by point, check if it's the good one. Do something like in part 1, checking for an empty space checking line by line. Check the positions just beyond the

Re: [Jprogramming] Questions on day 15th of Advent of code 2022, optimization woes

2022-12-15 Thread Raul Miller
Yes, after I sent that suggestion, I realized that I could do a better job of describing the approach. So, I sat down and implemented the thing that way. My implementation could do with some code cleanup, but as it stands now, it looks like this performance wise: timespacex '4e6 B input' 0.02

Re: [Jprogramming] Questions on day 15th of Advent of code 2022, optimization woes

2022-12-15 Thread Raul Miller
Here's a somewhat presentable implementation of part 2 for day 15. it's a bit different from what I described in my previous email, but most of the concepts are the same. NUM=: '-',~.":i.10 parse=: 0 ". (#~ e.&NUM);._2 prep=: {{ 'S Be'=: _2 j./\ |: (\: 1{"1]) parse y }} mhd=: +/@:|@+.@- edge=: {{

Re: [Jprogramming] Questions on day 15th of Advent of code 2022, optimization woes

2022-12-15 Thread Jaume
That's the kind of code I'm aspiring to write :D Still some distance away. Great job! Missatge de Raul Miller del dia dv., 16 de des. 2022 a les 2:47: > Here's a somewhat presentable implementation of part 2 for day 15. > it's a bit different from what I described in my previous email, but > m