this post was submitted on 01 Dec 2023
18 points (100.0% liked)
NotAwfulTech
386 readers
4 users here now
a community for posting cool tech news you don’t want to sneer at
non-awfulness of tech is not required or else we wouldn’t have any posts
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Day 18: Lavaduct Lagoon
[Language: jq]
https://github.com/zogwarg/advent-of-code/blob/main/2023/jq/18-b.jqSatisfyingly short (in lines, not in time writing) some of the longer part is hexadecimal parsing, that doesn't come natively in JQ, I started doing polygon math from part 1, and what took me the longest was properly handling the area contributed by the perimeter. (I toyed with trying very annoying things like computing the outmost vertex at each turn, which is complicated by the fact that you don't initially know which way the digger is turning, and needing previous and next point to disambiguate).
Day 19: Aplenty
[Language: jq]
https://github.com/zogwarg/advent-of-code/blob/main/2023/jq/19-b.jqSatisfyingly very well suited to JQ once you are used to the
stream
,foreach(init; mod; extract)
andrecurse(exp)
[where every output item of exp as a stream is fed back into recurse] operators. It's a different way of coding but has a certain elegance IMO. This was actually quick to implement, along with re-using the treating a range as a primitive approach of the seeds-to-soil day.EDIT: Less-thans and greater-thans replaced by fullwidth version, because lemmy is a hungry little goblin.
Nice!
Also, kudos for working with polygon area from the start. I was too invested in reusing my code as discussed elsewhere, but I came around in the end.19 was a real pain in dart.