Re: [Jprogramming] Advent of Code Day 24

2022-01-22 Thread Raul Miller
And... I forgot to mention: the second column of my r (the first column of your r) contains [partial] serial numbers (corresponding to the z value in the first column of my r (the second column of your r)). Conceptually, the second column is 0, then ,.D then ,.10 #.>,{D;D then ,.10 #.>,{D;D;D and

Re: [Jprogramming] Advent of Code Day 24

2022-01-22 Thread Stefan Baumann
Very inspiring… 3 things I was not aware of: * „cut“ and how you use it with obverse ; in combination with &. * 'I0‘~ evokes the verb I0 * 'q r'=. automatically unboxes a boxed argument and the nice use case for fold F.. Thanks. Stefan. On Fri 21. Jan 2022 at 2:35 PM, Raul Miller wrote: > Her

Re: [Jprogramming] Advent of Code Day 24

2022-01-21 Thread Raul Miller
Here's a rephrasing of your (Stefan Baumann's) approach. Here, input contains the text of the AoC supplied input.txt file: input=: fread '~/Documents/aoc24input.txt' D=:1+i.9 M=: <;._1'/inp w/:/-/_/add/+/mul/*/div/<.@%/mod/|~/eql/=' I=: ;@|."1(3 1 3 2 4 0{'[';'=.';])&.(cut :.;)L:0;._1<;._2 rplc&M

Re: [Jprogramming] Advent of Code Day 24

2022-01-21 Thread Raul Miller
I should add, after studying this a bit more: It looks you are also tracking the "maximum z value" from each digit's block of code -- p is the maximum z value from the previous block, and q is the maximum z value from the block before that -- and when q is greater than the minimum z value of the c

Re: [Jprogramming] Advent of Code Day 24

2022-01-21 Thread 'Rob Hodgkinson' via Programming
I agree, good job Raul and all contributing, was interesting to follow approaches. Thanks > On 21 Jan 2022, at 7:29 pm, Stefan Baumann wrote: > > Many thanks for your comments - I really need to increase usage of the > Foreigns documentation when searching for solutions... > > And all the mor

Re: [Jprogramming] Advent of Code Day 24

2022-01-21 Thread Stefan Baumann
Many thanks for your comments - I really need to increase usage of the Foreigns documentation when searching for solutions... And all the more, thank you so much for initiating these AoC threads, they were a big pleasure to read! Stefan. On Thu, Jan 20, 2022 at 8:47 PM Raul Miller wrote: > Hm

Re: [Jprogramming] Advent of Code Day 24

2022-01-20 Thread Raul Miller
Hmm... that's really neat. Personally, I would use J's cut rather than <;._1 ' '&, but that's pretty minor. (Also, I got rid of the fwrite -- to inspect i, I instead used 9!:37]4$0 512). (Also, for my own sanity, I removed the "0 from the trailing edge of the i0..i13 verbs and instead put had i',

Re: [Jprogramming] Advent of Code Day 24

2022-01-20 Thread Stefan Baumann
Almost gave up on that one - but got it solved somehow and still don't know why it works... I started to parse the instructions into 14 iteration verbs i0-i13. For this I used a mapping m for translating instructions into J verbs - mapping inp to : is merely used for splitting; the jx verb then cre

Re: [Jprogramming] Advent of Code Day 24

2022-01-16 Thread Raul Miller
On Sun, Jan 16, 2022 at 12:34 PM 'Michael Day' via Programming wrote: > OK - your approach is far more efficient than mine! I suspect you did > what I had in mind, but couldn't quite get that mind to produce. I should perhaps add.. My first (reverse) pass through the possibilities did not conce

Re: [Jprogramming] Advent of Code Day 24

2022-01-16 Thread Raul Miller
On Sun, Jan 16, 2022 at 12:34 PM 'Michael Day' via Programming wrote: > I see that you (Raul) didn't bother with truncating divide towards > zero. In testing, I fell foul of this, > and used > divt =: {{ s * y <.@%~ | x [ s =. * x }} > ... but I think you're ok in the actual "program" as d

Re: [Jprogramming] Advent of Code Day 24

2022-01-16 Thread 'Michael Day' via Programming
OK - your approach is far more efficient than mine!  I suspect you did what I had in mind, but couldn't quite get that mind to produce. I see that you (Raul) didn't bother with truncating divide towards zero.  In testing,  I fell foul of this, and used    divt =: {{ s * y <.@%~ | x   [ s =. *

Re: [Jprogramming] Advent of Code Day 24

2022-01-15 Thread Raul Miller
Also, after reflection, it turns out that getting rid of the if statement was straightforward: BLOCK=: {{ W=: x{::digits X7=: W~:/(x{B)+26|y ((W+x{A)*X7)+(1+25*X7)*"(X7 <.&#&$ t)t=.<.y%x{C }} By the way, in case it was not obvious -- the 7 (in X7) refers to the line number of that assignme

Re: [Jprogramming] Advent of Code Day 24

2022-01-15 Thread 'Michael Day' via Programming
... and it's one of those "days" that part 2 is ridiculously easy cf part 1 !!! Mike On 15/01/2022 21:15, 'Michael Day' via Programming wrote: Yes, that's my guess.  I called them p q & r,  and found that p = 1 or 26 as q is positive or negative. So: having got one machine to run 14 times on

Re: [Jprogramming] Advent of Code Day 24

2022-01-15 Thread 'Michael Day' via Programming
Yes, that's my guess.  I called them p q & r,  and found that p = 1 or 26 as q is positive or negative. So: having got one machine to run 14 times on different values of p q r and the previous Z, I worked back from Z = 0 output on the 14th machine,  saving which W & Zs gave rise to 0,  then us

Re: [Jprogramming] Advent of Code Day 24

2022-01-15 Thread Raul Miller
Actually, another caution here: it might be that other people's puzzle inputs used a different block structure from my block structure. Probably not -- it's probably the case that only my A, B and C values differed for different people. But .. that's just "probably" because I haven't looked at oth

Re: [Jprogramming] Advent of Code Day 24

2022-01-15 Thread Raul Miller
I've got this solved now, Eugene Nonko put me on the right path here. The trick, from my perspective, was to convert the machine code into executable J. And, to ensure that I could use J's dimensionality to manage multiple tests at the same time. Specifically, I parameterized the three "block s

Re: [Jprogramming] Advent of Code Day 24

2022-01-14 Thread Raul Miller
Eugene is way ahead of us here -- and I think his observation was not so much specifically about this structural issue but instead a consequence of this issue. Subtle distinction, perhaps... -- Raul On Fri, Jan 14, 2022 at 9:20 AM 'Michael Day' via Programming wrote: > > Apologies to Eugene No

Re: [Jprogramming] Advent of Code Day 24

2022-01-14 Thread 'Michael Day' via Programming
Apologies to Eugene Nonko - I'd overlooked your remarks about the great similarity between the 14 segments.  Plagiarism rules! Mike On 13/01/2022 23:34, Eugene Nonko wrote: I did solve it, but I didn't use J for that one. I wrote a translator in Perl that converted their assembly into C. C, b

Re: [Jprogramming] Advent of Code Day 24

2022-01-14 Thread 'Michael Day' via Programming
We haven't seen part 2 yet,  of course... there could be another sting in the tail, judging by the number of part 2 finishers in the stats! Mike On 14/01/2022 14:01, Raul Miller wrote: On Fri, Jan 14, 2022 at 4:15 AM 'Mike Day' via Programming wrote: My data has, of course, 14 inp ops; to my

Re: [Jprogramming] Advent of Code Day 24

2022-01-14 Thread Raul Miller
On Fri, Jan 14, 2022 at 4:15 AM 'Mike Day' via Programming wrote: > My data has, of course, 14 inp ops; to my surprise these were ops 0 > 18 36 ... Tabulating the data as 14 boxes of 18 ops, the ops and > first arguments were identical in each box; I think this applies to > all those second argum

Re: [Jprogramming] Advent of Code Day 24

2022-01-14 Thread 'Mike Day' via Programming
I’ve just got going on this after throwing in the towel on 23.2, though I haven’t yet persuaded myself to crib your post on that one! It’s one of those days where Dyalog APL’s direct definitions, where alpha and omega are the default arguments, would have saved renaming the registers to upper

Re: [Jprogramming] Advent of Code Day 24

2022-01-13 Thread Eugene Nonko
I did solve it, but I didn't use J for that one. I wrote a translator in Perl that converted their assembly into C. C, because it's easier to read, plus I thought that some brute forcing might be required and compiled C will run faster than interpreting their assembly. While studying that generat

[Jprogramming] Advent of Code Day 24

2022-01-13 Thread Raul Miller
https://adventofcode.com/2021/day/24 I have not completed the day 24 puzzle. The day 24 puzzle has a sequence of instructions representing a calculation to verify a model number (and conceptually enable features based on that model number -- though part A of the puzzle does not provide any detail