Live data from Hacker News

Advent of Code 2024

adventofcode.com

521–530 of 580 posts

Re: Advent of Code 2024

#521

I love AoC! Did it the last 2-3 years in Rust, hanging out in a discord where we all try to make the absolute fastest solutions. Learnt all kinds of crazy performance hacks and some advanced algorithms & SIMD that way. This time I'm trying to do them in Rust and Golang in an effort to either learn to like/tolerate Golang (because we use it at work) or prove my hypothesis that it sucks and never use it unless I have t…

Is there a discord every year? Interested in joining that if you don’t mind sharing

Re: Advent of Code 2024

#523
post #159

I usually do AoC in Common Lisp, but this year I'm giving Swift a chance. It's not half bad at this kind of twiddling for being a statically typed mainstream language. https://github.com/codr7/aoc24/tree/main/swift/Sources/aoc This year is a tiny bit weird, I was just getting ramped up organizing the event at a new job; because I think it's very useful for devs to learn some real problem solving, as opposed to stitch…

dont you find all the string parsing and manipulation to be quite painful in Swift? I tried to do AoC in Swift before and that put me off a lot. I liked doing little functional one liners but a week from now the parsing burden will be too high.

I program everyday in Swift. I attempted AoC for the first time in Swift last year and gave up after about a week or so for this exact reason and switched to python for the remainder. I don't want to struggle with the awkward string API to do things other languages can do in a line.

Re: Advent of Code 2024

#524

Earlier quoted context omitted.

dont you find all the string parsing and manipulation to be quite painful in Swift? I tried to do AoC in Swift before and that put me off a lot. I liked doing little functional one liners but a week from now the parsing burden will be too high.

I program everyday in Swift. I attempted AoC for the first time in Swift last year and gave up after about a week or so for this exact reason and switched to python for the remainder. I don't want to struggle with the awkward string API to do things other languages can do in a line.

I'm curious, any specific examples you can remember?

Re: Advent of Code 2024

#525
post #159

I usually do AoC in Common Lisp, but this year I'm giving Swift a chance. It's not half bad at this kind of twiddling for being a statically typed mainstream language. https://github.com/codr7/aoc24/tree/main/swift/Sources/aoc This year is a tiny bit weird, I was just getting ramped up organizing the event at a new job; because I think it's very useful for devs to learn some real problem solving, as opposed to stitch…

dont you find all the string parsing and manipulation to be quite painful in Swift? I tried to do AoC in Swift before and that put me off a lot. I liked doing little functional one liners but a week from now the parsing burden will be too high.

I found the Scanner API (1) to be pretty handy for the more complex parsing in past years.

It’s Foundation so hopefully also on Linux/Windows, but if not there’s also one on GitHub called SwiftScanner.

1: https://developer.apple.com/documentation/foundation/scanner

Re: Advent of Code 2024

#526

This years challenge for me: write it in C without the standard library or an allocator. Has to be runnable on an STM32 with 32kb of SRAM. I tried doing it in Assembly two years ago, ended up spending hours and hours writing an Assembly standard library, then gave up and switched to Rust...

Assembly is so much cleaner on an STM8 8-bit. If you’re into that sort of masochism

Re: Advent of Code 2024

#527

Last year I got stuck on Day 12 for a full week, and thinking about how to solve it consumed my every waking moment. I think this year, I'm going to be kind to myself and not participate so I can really enjoy the winter break from work.

I got stuck on the graph-cut puzzle for FOUR MONTHS. I had to write a force-directed graphing engine to find the longest three edges to cut. After I solved it I looked at other people's solutions and they used Meta's proposition solver in about 10 lines. Seemed like a massive cheat to me.

This was the day 25 problem: given a graph of ~1600 nodes and ~3500 edges, find the 3 edges that if deleted divide the graph into 2 components. I looked over some of the solutions and it surprised me how few used the simplest method: for each edge with endpoints u, v in the graph, delete it and then find another path P1 between u and v. Then, for each edge e1 in P1, delete it and then find another path P2 between u and v. Then, for each edge e2 in P2, delete it and then try to find another path between u and v. If there is no path, (u, v), e1, e2 is your cut-set. Otherwise, add e2 back and try the next edge in P2. When you've exhausted P2, add e1 back and try the next edge in P1. When you've exhausted P1, add (u, v) back and try the next edge in the graph. It's 3-6 loops deep depending on how you count, but it works. My python implementation completes in under 2 minutes, but it varies because it appears the standard python data structures have some nondeterminism, and I may have had a lucky draw with my puzzle input.

Re: Advent of Code 2024

#528
co-pilot solved day 2 in a second, kind of makes me sad. I’ll try some of the others myself though they’re kond of fun. Would be fun to use as many languages as possible or maybe some convoluted micro services architecture.

Re: Advent of Code 2024

#529

Earlier quoted context omitted.

I thought the Amiga 1k had page protection, just not virtual memory?

No, there's no MMU.

Well, apparently if your CPU has one (030+) you can use something like Enforcer (http://www.sinz.org/Michael.Sinz/Enforcer/). I’ve yet to try it.

Re: Advent of Code 2024

#530

Earlier quoted context omitted.

How do you structure your aoc project? I tried doing Rust, but I'm too dumb to figure out if each day should be a module or if I should use lib (I guess?) files for each day and link everything to a main entry point. Can you share your repo (if public)?

Take a look at my repo - http://github.com/nindalf/advent-2024 Each day is a new module, this way I don't have to think of new names for part1() and part2(). I can still import code from the rest of the crate if I want with `use crate::`. If you like this style of structuring the project, you may be interested in the generator I use for it - http://github.com/nindalf/aocgen . `aocgen --day 2` will create these files…

Looks pretty neat I'll take some inspiration from this.

Though you shouldn't upload the text and inputs of the puzzles (maybe .gitignore them) as per [0]:

> Can I copy/redistribute part of Advent of Code? Please don't. Advent of Code is free to use, not free to copy. If you're posting a code repository somewhere, please don't include parts of Advent of Code like the puzzle text or your inputs. If you're making a website, please don't make it look like Advent of Code or name it something similar.

[0]: https://adventofcode.com/2024/about

Post reply on HN