Not a bad habit if you put the globals into a locale, I say.
Henry Rich
On 1/18/2022 6:46 PM, Raul Miller wrote:
I definitely see the appeal of a recursive solution which avoids globals.
That said, I've been parsing enough really large files that I've
gotten into the habit of using globals for
I definitely see the appeal of a recursive solution which avoids globals.
That said, I've been parsing enough really large files that I've
gotten into the habit of using globals for managing parsing state.
Plausibly a *bad* habit...
Here, I could have made the data dependencies explicit by passin
Hi, very interesting to read different takes on the problem!
I made it recursive, passing around whatever remains of the bit string,
with no use of global state (just some auxiliary verbs and the list of
operations). A trick I was particularly happy with is combining the
stopping condition on pack
I think you could use X ;: bits where bits is a sequence of '0' and
'1' characters, if you used ;: opcode 6 (stop) on reaching the payload
part of the packet.
An example implementation would then interpret the first word of the
result as the puzzle opcode. If the opcode was 4, it would interpret
t
I didn't get a grip on this problem at the beginning and skipped it.
But inspired by Raul's solution it appeared that the problem input looks
like an encoded LISP expression.
So I tried to parse the data into a LISP-like J expression and was
wondering if I could then apply ". on it.
The parsing ver
I have begun to punt on the aoc about here.
Even with this part a solution I got frustrated thinking about the parsing
of "operator" packets even on part a. Your explanation and code is very
informative. For example in this day 16 question the snippet below was very
satisfying because I could not s
So your parse is akin to my unpack.
I was going to say that my "operator" and "literal" were both dyadic
too, but checked,
and now find I'm wrong. But "unpack" itself is indeed dyadic; irs
input is initially 0 _ ,
holding the required part 1 total, and the number of sub-packets where
relev
Mine is recursive: parse calls operator, and operator calls parse.
That's why I added a trace mechanism (an echo statement showing the
string I used to represent what would happen to the value, along with
the value itself, for each packet) -- so that I could visualize what
was happening.
By the w
I’d forgotten that this day was also pretty hard. My “unpack” function (snap!)
also delivered the goods for both parts. It works through the message calling
either “literal” or “operator”. literal is self-contained, returning a value
and an unused message fragment, while operator calls unpack
https://adventofcode.com/2021/day/16
Here, we were decoding messages encoded using the AoC "BITS" protocol.
A significant part of the puzzle was about comprehending the somewhat
shiftless protocol specification included in the puzzle.
The approach I found useful was to set up a "test bench" with
10 matches
Mail list logo