Live data from Hacker News

Advent of Code 2024

adventofcode.com

561–570 of 580 posts

Re: Advent of Code 2024

#561

Earlier quoted context omitted.

Heh. Yeah, a memfault tanking the machine is not conducive to iterative programming :o)

Just stop writing memfault. I say it in jest but that's actually how I used to program a few years ago when I was working on large industrial pieces of software with long compilation time. You just have to be careful and check what you wrote before sending it to the machine. I think "iterative" programming has made people really complacent when it comes to silly errors. Slowing down can often do wonder.

I feel like if you're writing C then writing with memory safety in mind should probably be autonomous anyway

Re: Advent of Code 2024

#562

Earlier quoted context omitted.

AmigaOS has no memory protection whatsoever. If your program crashes, so does the entire machine. And it will possibly bring your hard drive with it, too. Not unworkable, but not the most relaxed environment for fast’n’fun cowboy coding. You typically have to reboot a lot.

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

No MMU.

A1000 has... something. The WORM (write once read many), RAM used for the kickstart, which is latched as read-only after the kickstart has been loaded from floppy by the bootstrap ROM.

Re: Advent of Code 2024

#563

I'm doing the challenges in PowerShell to see how it goes. I want to use it as a test to see how human programming can be improved by an AI, so I wrote the solution for day 1, got the right answer, and then gave my code to ChatGPT 4o to ask it to make the code faster. My version ran in ~3500 ms ChatGPT's version ran in 140 ms both worked A great example of how a common DevOps language program can be improved on by Ch…

That seems rather slow for yours, and not very fast for an optimised one. It can speed up a lot from a cold start to a warm run, my tuned code can show 8 ms in powershell 7.4 after a few runs. My hack-it-out code: https://pastebin.com/PDQhxDc9 Faster code: https://pastebin.com/6xwaVkwq The hacky code uses slower techniques like: - Get-Content which adds metadata to every line. - @() arrays with += which copies the ar…

Great to see your optimizations.

I'm going through each day and asking ChatGPT to speed it up, it doesn't always work, but that is the way of the Gippity.

The payoff is these heavy iterating operational scripts I run for work will end up running faster :)

Learning when to lean on some of the .NET primitives really helps speed up PS as it likes to wrap things with unnecessary features.

Re: Advent of Code 2024

#564

Earlier quoted context omitted.

That all well and good until you hit a brick wall you cannot pass. At this point a helping hand and/or the answer is the only way forward or to learn.

> you cannot pass This is his entire point: getting to this brick wall is _where_ the real learning happens. When you start scrambling, reading old stackoverflow posts, and breaking out the calculus text book you're pushing the boundaries of what is possible for you. Body builders don't grow by watching other people lift weights.

But if you want weights lifted, you don't use bodybuilders.

Re: Advent of Code 2024

#565

I will try to do it with F# and Gleam this year, but like every year I won’t have time (and brain) to do more than 10/12 days ^^ For the pythonists around here, give F# a try: it can feels very close to scripting and it has a wonderful REPL too :)

Nice. I've started picking up F# too and am trying AoC with it this year. I'm still early in my functional journey, but I think AoC has been helpful thus far.

Re: Advent of Code 2024

#566

Earlier quoted context omitted.

That seems rather slow for yours, and not very fast for an optimised one. It can speed up a lot from a cold start to a warm run, my tuned code can show 8 ms in powershell 7.4 after a few runs. My hack-it-out code: https://pastebin.com/PDQhxDc9 Faster code: https://pastebin.com/6xwaVkwq The hacky code uses slower techniques like: - Get-Content which adds metadata to every line. - @() arrays with += which copies the ar…

Great to see your optimizations. I'm going through each day and asking ChatGPT to speed it up, it doesn't always work, but that is the way of the Gippity. The payoff is these heavy iterating operational scripts I run for work will end up running faster :) Learning when to lean on some of the .NET primitives really helps speed up PS as it likes to wrap things with unnecessary features.

You may find Claude giving better results. You can ask her to write code with "please apply technical guidance from Stephen Toub w.r.t. performance to the code you come up with" and it helps to improve the quality since Stephen Toub is someone she knows about. Or maybe some other core contributors and article authors that have more likelihood to be present in the dataset.

Re: Advent of Code 2024

#567
post #153

Am I alone in thinking that measuring time to get answer is the worst possible metric? I have not participated because of that (yet). If there is a community for those who use other rules to compare actual solutions instead of answers I would be interested to hear about it. I am coming from low level C++ gamedev side so I understand that most people here use different tools to solve different problems.

Here's a website that appears to be about competing on the performance of each solution: https://codspeed.io/advent

After trying to turn day 4 part 2 as example to my colleagues I came back to check the site. Day 1 winner seems like what I would have expected so thanks for the link!

Sry, can't upvote because I mostly read HN not logged in so I still can't upvote. If there were some other performance oriented forums either on reddit or somewhere I seem to be too lazy to find them anyway.

Re: Advent of Code 2024

#568

> You don't need a computer science background to participate - just a little programming knowledge and some problem solving skills will get you pretty far. The use of “pretty far” gives them a bit of an out, but I think this statement is a little disingenuous. Last year, at least, a bunch of the problems needed fairly sophisticated algorithms to find the solution in a reasonable amount of time. To me, a little progr…

Anecdote to support your comment: The Chinese Remainder Theorem has featured in Advent of Code at least twice IIRC. Not an algorithm the average programmer (average is a very fuzzy term, yeah) would know.

Got some specific references for the days that was required?

I think a lot of people are so focused on "optimal" solutions they fail out or burn out quickly, ignoring the ugly "just loop a bunch of things" option.

I'm by far an expert on AoC, but the number of people I see every year on day 2 or 3 saying "IT'S TOO MUCH" because they were trying to implement some crazy algorithm when basic array operations and for loops would solve it...

I flunked out of high school. I don't even properly understand algebra, never mind any sort of complex math. I have no CS degree. I've completed most of it in some gross PHP that completed before next year on a single core in an old laptop.

If "knowledge of obscure algorithms" is a requirement either I'm a once in a generation genius or... it's not a requirement.

Re: Advent of Code 2024

#569
I have seen a couple of snarky comments about how AoC is just a competition for who can write an input parser the fastest for 25 days in a row, I'll just share the following:

Just write that once, put it in a template /day0 folder that has /day0/part1, /day0/part2, and /day0/input.txt, and then just copy it and focus on the actual problem. It's all about having fun!

Re: Advent of Code 2024

#570
post #542
post #138

I’m using sqlite this year. Hoping that there won’t be any computational geometry or trie problems. Kind of hoping for a graph problem solvable with recursive CTEs, that would be cool.

As every year, I try to solve it with 1 sql statement for every challenge, https://gitlab.com/feike/adventofcode/-/tree/master/2024 , likely going to get stuck again around day 12/13 or so!

Awesome! Thanks for sharing. It feels good to have some company in this, I will follow your progress!

I created a repo for my solutions here: https://github.com/lyxell/aoc2024-sqlite

Update: Wow. Reading your solutions was a real eye-opener for me. It never struck me that one can exploit the fact that unmaterialized CTE's will not be evaluated for rows that is not needed by another SELECT and one can use this the same way one uses laziness in Haskell. This is great stuff, thanks again for sharing!

Post reply on HN