this post was submitted on 01 Dec 2023
17 points (100.0% liked)
NotAwfulTech
357 readers
1 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 9: Mirage Maintenance
My solution: https://github.com/gustafe/aoc2023/blob/main/d09-Mirage-Maintenance.pl
discussion
What can I say. Shockingly simple.I just literally followed the instructions, and got a solution in 20ms. This despite literally creating each intermediate array yet only using the ends. I'm sure I used way to much memory but you know? I'm using a $5/mo VPS for everything and unless I'm barking totally up the wrong tree I've never exceeded its memory limits.
On the subreddit I see people discussing recursion and "dynamic programming" (which is an empty signifier imho) but I really don't see the need, unless you wanna be "elegant"
spoiler
DP to me is when you use memoisation and sometimes recursion and you want to feel smarter about what you did.I also struggle to think of the need for DP, even in a more “elegant” approach. Maybe if you wanted to do an O(n) memory solution instead of n^2, or something. Not saying this out of derision. I do like looking at elegant code, sometimes you learn something.
I feel like there’s an unreadable Perl one line solution to this problem, wanna give that a go, @gerikson?
spoiler
Part 2 only, but Part 1 is very similar.I'm pretty sure you could make this one line and unreadable ^^.
Now this is content
Here's where I landed in dart
no comments