Re: [Jprogramming] Advent of Code Day 12

2022-01-16 Thread P Padilcdx
Ah that makes sense. Thank you! Slowly getting it… Appreciate all the help and patience. > On Jan 16, 2022, at 8:58 PM, Hauke Rehr wrote: > > No, u&v works differently: > > a silly example: > - 4 > _4 > - 5 > _5 > NB. these all do the same: > _4 + _5 > _9 > (- 4) + (- 5) > _9 > 4 +&

Re: [Jprogramming] Advent of Code Day 12

2022-01-16 Thread Hauke Rehr
No, u&v works differently: a silly example: - 4 _4 - 5 _5 NB. these all do the same: _4 + _5 _9 (- 4) + (- 5) _9 4 +&- 5 _9 So dyadic x u&v y applies v monadicly to both x and y, u then applies dyadicly to (v x) and (v y) x u&v y ←→ (v x) u (v y) eg pythagoras %: 3 +&*: 4

Re: [Jprogramming] Advent of Code Day 12

2022-01-16 Thread P Padilcdx
What I don’t quite understand was the expansion of -.&;:&’-‘ y to y (-.&;:) ‘-‘ and then (;: y) -. (;: ‘-‘) So I was thinking the -.&;: is a hook. Complete newbie, so apologies. > On Jan 16, 2022, at 8:46 PM, Hauke Rehr wrote: > > I don’t quite understand. > LHS is just the result of applyi

Re: [Jprogramming] Advent of Code Day 12

2022-01-16 Thread Hauke Rehr
I don’t quite understand. LHS is just the result of applying ;: to the value 'start-A'. Am 17.01.22 um 05:45 schrieb P Padilcdx: That helps. What rule applies for making the LHS? Is it a hook? Thank You!! On Jan 16, 2022, at 8:09 PM, Hauke Rehr wrote: Maybe I should elaborate on this a bit

Re: [Jprogramming] Advent of Code Day 12

2022-01-16 Thread P Padilcdx
That helps. What rule applies for making the LHS? Is it a hook? Thank You!! > On Jan 16, 2022, at 8:09 PM, Hauke Rehr wrote: > > Maybe I should elaborate on this a bit more: > > ] LHS =: ;: 'start-A' > ┌─┬─┬─┐ > │start│-│A│ > └─┴─┴─┘ > ] RHS =: ;: '-' > ┌─┐ > │-│ > └─┘ > LHS -. RHS

Re: [Jprogramming] Advent of Code Day 12

2022-01-16 Thread Hauke Rehr
Maybe I should elaborate on this a bit more: ] LHS =: ;: 'start-A' ┌─┬─┬─┐ │start│-│A│ └─┴─┴─┘ ] RHS =: ;: '-' ┌─┐ │-│ └─┘ LHS -. RHS ┌─┬─┐ │start│A│ └─┴─┘ (;: 'start-A') -. (;: '-') ┌─┬─┐ │start│A│ └─┴─┘ Or was the missing link for you somewhere else? Am 17.01.

Re: [Jprogramming] Advent of Code Day 12

2022-01-16 Thread Hauke Rehr
First, you apply ;._2 Then it’s just a row-wise -.&;: eg 'start-A' (-.&;:) '-' ┌─┬─┐ │start│A│ └─┴─┘ Am 17.01.22 um 04:01 schrieb P Padilcdx: Slowly following the discussion. I confess I’m stuck at how the composition of -.&;:&’-‘ work in the unpack verb. Try to read the descripti

Re: [Jprogramming] Advent of Code Day 12

2022-01-16 Thread P Padilcdx
Slowly following the discussion. I confess I’m stuck at how the composition of -.&;:&’-‘ work in the unpack verb. Try to read the description of & in NuVoc and LJ, but i confess to still be clueless as to how J parses it. I experimented a bit but still perplexed. Can someone point me in the ri

Re: [Jprogramming] Advent of Code Day 12

2022-01-02 Thread Brian Schott
Raul, Yes, I was misunderstanding the first "bond" step. I could not see (-.&;:) as u in u&n . That does move 'start-A' to the left and leaves '-' on the right of the verb u. Great, I see it now. Thanks, On Sun, Jan 2, 2022 at 5:31 PM Raul Miller wrote: [snip] (-.&;:)&'-' 'start-A' >'sta

Re: [Jprogramming] Advent of Code Day 12

2022-01-02 Thread Raul Miller
I wrote that sentence before I added the 5!:6 content to the message, and I didn't think to rebuild it afterwards, even though the parenthesis in the 5!:6 result sufficiently illustrate that aspect of the grammar (and do a better job of describing that aspect than that "grammar rules" quip). Also,

Re: [Jprogramming] Advent of Code Day 12

2022-01-02 Thread Brian Schott
Raul, Thanks for the explanation. But you do not explicitly clarify in the following how the grammar rules do the expansion. unexplained part below** But let's break this down formally. The sentence in question is formed using conjunctions. In other words, we could expan

Re: [Jprogramming] Advent of Code Day 12

2022-01-02 Thread Raul Miller
Certainly... unpack=:-.&;:&'-';._2 sample=: unpack S=: {{)n start-A start-b A-c A-b b-d A-end b-end }} Note that I've added a variable to capture the upstream noun which unpack will process. So, we're looking at this: unpack S +-+---+ |start|A | +-+---+ |start|b | +-+---+ |A

Re: [Jprogramming] Advent of Code Day 12

2022-01-02 Thread Brian Schott
Raul, I cannot understand how *unpack* works. When I use 9!:3]6 to display *unpack* I get the following. ((-.&;:)&'-');._2 But that does not help me because I cannot process the parenthesized parts separately. The only "part" I can process is ;: ;. _2 in where *in* is defined as follows.

Re: [Jprogramming] Advent of Code Day 12

2022-01-02 Thread Jan-Pieter Jacobs
Actually, 'in' is a wrapper for fread that reads the input file. I forgot to include it this time, sorry. It's defined as: in=: [: freads '.txt' ,~ _2 {.!.'0' ": NB. read input of day y (given as num) and I keep each day's input in a file named dd.txt, with dd the 2 digit day number. On Sun, Jan

Re: [Jprogramming] Advent of Code Day 12

2022-01-02 Thread Brian Schott
I think I understand that Jan-Pieter has a data noun named in12 which I reproduce here. in12 =: 0 : 0 start-A start-b A-c A-b b-d A-end b-end ) Then that line of code, but ending in in12 instead of in 12, works. -- For informa

Re: [Jprogramming] Advent of Code Day 12

2022-01-02 Thread Raul Miller
I had a little problem with your code here. You had a lot of long lines, which got wrapped in email (mostly comment lines). I think I have those all sorted out now, But, I also got this: |value error: in | i12=:(sl{."1)([:sl[:<;._2,&'-');._2 in 12 If I change that line to i12=:(sl{."1)([:s

Re: [Jprogramming] Advent of Code Day 12

2022-01-02 Thread Jan-Pieter Jacobs
I think mine is pretty much the same idea as Raul's for part 1, tough I used symbols rather than integers for encoding the caves (nodes). NB. Day 12: Cave mapping paths sl=: (\: #&>) NB. sort boxes by descending length NB. remove - and sort boxes by length s.t. start, end are first: unordered edge

[Jprogramming] Advent of Code Day 12

2022-01-01 Thread Raul Miller
https://adventofcode.com/2021/day/12 For day 12, we had a "cave map" which was a list of connections between named pairs of rooms. unpack=:-.&;:&'-';._2 sample=: unpack {{)n start-A start-b A-c A-b b-d A-end b-end }} Here, our puzzle task, for part A, was to explore the cave system. We needed t

Re: [Jprogramming] advent of code day 12

2015-12-14 Thread Alex Shroyer
anks for sharing. >> >> >> >> >> - Original Message - >> From: Henry Rich >> To: programm...@jsoftware.com >> Sent: Saturday, December 12, 2015 10:12 PM >> Subject: Re: [Jprogramming] advent of code day 12 >> >> Spurning conve

Re: [Jprogramming] advent of code day 12

2015-12-13 Thread Henry Rich
te: very impressive, Henry. thanks for sharing. - Original Message - From: Henry Rich To: programm...@jsoftware.com Sent: Saturday, December 12, 2015 10:12 PM Subject: Re: [Jprogramming] advent of code day 12 Spurning convert/json. A nonrecursive solution: NB. advent 12 NB. part 1

Re: [Jprogramming] advent of code day 12

2015-12-13 Thread Joe Bogner
@(0&{))`($: each)@.(0 >~ L.) smoutput pt2=: +/ ; S:0 (traverse json) On Sat, Dec 12, 2015 at 11:35 PM, 'Pascal Jasmin' via Programming wrote: > very impressive, Henry. thanks for sharing. > > > > > - Original Message - > From: Henry Rich > To:

Re: [Jprogramming] advent of code day 12

2015-12-12 Thread 'Pascal Jasmin' via Programming
very impressive, Henry. thanks for sharing. - Original Message - From: Henry Rich To: programm...@jsoftware.com Sent: Saturday, December 12, 2015 10:12 PM Subject: Re: [Jprogramming] advent of code day 12 Spurning convert/json. A nonrecursive solution: NB. advent 12 NB. part 1

Re: [Jprogramming] advent of code day 12

2015-12-12 Thread Henry Rich
Spurning convert/json. A nonrecursive solution: NB. advent 12 NB. part 1 i =: <@;:;._2 iraw =. wd 'clippaste' +/ (0&".@;;.2~ ~:&(<,'-')) (#~ '-0123456789' e.~ {.@>) ;i NB. part 2 NB. Assign nesting level to each character; make level of } match { nlevel =: (+/\ + _1&=) class =: 1 _1 0 {~

Re: [Jprogramming] advent of code day 12

2015-12-12 Thread 'Pascal Jasmin' via Programming
test with. - Original Message - From: Joe Bogner To: programm...@jsoftware.com Sent: Saturday, December 12, 2015 5:36 PM Subject: Re: [Jprogramming] advent of code day 12 I think mine produces the right answer. With your input, I get the following which matches someone else's

Re: [Jprogramming] advent of code day 12

2015-12-12 Thread Joe Bogner
ou're ommitting a transformation of the input, but here is mine. > > > https://gist.github.com/Pascal-J/bdd22d59fc07eb5a7b9a > > > > > - Original Message - > From: Joe Bogner > To: programm...@jsoftware.com > Sent: Saturday, December 12, 2015 4:58 PM >

Re: [Jprogramming] advent of code day 12

2015-12-12 Thread 'Pascal Jasmin' via Programming
ach traverse1 a > > includes a as its 2nd item in top row. > > > $ each a > > - Original Message - > From: Joe Bogner > To: programm...@jsoftware.com > Sent: Saturday, December 12, 2015 3:47 PM > Subject: [Jprogramming] advent of code day 12 > > somewhat

Re: [Jprogramming] advent of code day 12

2015-12-12 Thread Joe Bogner
t; includes a as its 2nd item in top row. > > > $ each a > > - Original Message ----- > From: Joe Bogner > To: programm...@jsoftware.com > Sent: Saturday, December 12, 2015 3:47 PM > Subject: [Jprogramming] advent of code day 12 > > somewhat tricky as I hadn&#x

Re: [Jprogramming] advent of code day 12

2015-12-12 Thread 'Pascal Jasmin' via Programming
row. $ each a - Original Message - From: Joe Bogner To: programm...@jsoftware.com Sent: Saturday, December 12, 2015 3:47 PM Subject: [Jprogramming] advent of code day 12 somewhat tricky as I hadn't done recursion in J prior to this: require 'convert/json' input =: fre

Re: [Jprogramming] advent of code day 12

2015-12-12 Thread Joe Bogner
Yes, this was my original part 1 +/ (". :: 0:) every ;: ('-';'_') stringreplace input 191164 On Dec 12, 2015 4:19 PM, "Moon S" wrote: > For part1 you don't need json actually ;) > > part1 =: 3 : 0 NB. replace all non-digits to spaces, replace '-' to '_', do > +/". > a=.'abcdefghijklmnopqrstuvw

Re: [Jprogramming] advent of code day 12

2015-12-12 Thread Moon S
For part1 you don't need json actually ;) part1 =: 3 : 0 NB. replace all non-digits to spaces, replace '-' to '_', do +/". a=.'abcdefghijklmnopqrstuvwxyz"'',[]{}:',CRLF +/". ('-';'_')rplc~ ' '((i.#y)#~+./a=/y)}y ) On Sat, Dec 12, 2015 at 10:47 PM, Joe Bogner wrote: > somewhat tricky as I h

[Jprogramming] advent of code day 12

2015-12-12 Thread Joe Bogner
somewhat tricky as I hadn't done recursion in J prior to this: require 'convert/json' input =: fread 'c:/joe/lang-lab/j/advent2015/day12.txt' json=: dec_json input traverse=: (".@":@(0&{))`($: each)@.(0 >~ L.) smoutput pt1=: +/ ; S:0 (traverse json) hasRed=:(<'red') e.~ [ NB. check for 1 in 2