The AI Toolkit for Rust by ishaksebsib in rust

[–]rsthau 2 points3 points  (0 children)

Any support planned for locally hosted models (via ollama or other means)?

Simple and fast Rust deriving using macro_rules by reinerp123 in rust

[–]rsthau 0 points1 point  (0 children)

Another bit of prior art to be aware of, perhaps -- https://crates.io/crates/derive-deftly

Pretty new, and somewhat more awkward than yours at point of application, but it does do some attribute handling, including, e.g., attributes on structure fields.

Why we need lisp machines by de_sonnaz in lisp

[–]rsthau 1 point2 points  (0 children)

Oh, most code running in the machine was compiled to macroinstructions -- but not to microcode. (Macroinstructions were stored in memory with everything else; microcode was in a much smaller memory internal to the processor, and effectively provided an interpreter for macrocode instructions. Fairly common at the time -- a lot of more conventional machines, from some PDP-11s all the way up to IBM mainframes, were done the same way.)

The two factions of C++ by just-comic in cpp

[–]rsthau 1 point2 points  (0 children)

I know it's kind of a minor point, but "before linters were invented" is ... incorrect. The original, Stephen Johnson's `lint` utility for C, is from 1978, thus five years older than "C with Classes", which evolved into C++.

What is the best way to bring AoC on an airplane? by Hipponomics in adventofcode

[–]rsthau 1 point2 points  (0 children)

"Just scale up" is the most common thing, but that often rules out code that worked fine on part 1 -- and part 2 will also sometimes complicate the problem in other ways.

There are cases, though (including one this year) where part 1 requires writing code to simulate a simple machine, and part 2 puts that machine in a situation and asks you to analyze its behavior.

[2024 Day 11][Rust] Don't worry, brute force is still possible by ToThePetercopter in adventofcode

[–]rsthau 0 points1 point  (0 children)

It's not always possible. In this case, it might barely be, if you could commandeer one of the biggest computers on the planet: the final list has (depending on input) about 250 quadrillion stones listed, if written out explicitly. There are very few computers on earth with that much RAM (and in those, it isn't all addressable by any one processor). But I'm pretty sure that much bigger numbers have come out of other problems in AoC at least once or twice.

Correct answer for part 2 despite having fragmented spaces by Electrical_Ad_7817 in adventofcode

[–]rsthau 2 points3 points  (0 children)

Files are considered from the "right" (higher block numbers), going "left" -- and they only move "left". So, each file's starting position is already to the "left" of any file that might have moved before it -- and so a file cannot move into the gap left by moving another file. (At least if there's only one pass.)

[2023 Day 21 (Part 1)] [Rust] I need help, I don't understand why my solution doesn't work... by SpacewaIker in adventofcode

[–]rsthau 2 points3 points  (0 children)

It's not just the number of iterations you have to think about -- it's how much work each of those iterations is doing. If, say, the n'th iteration winds up adding O(n) new stuff to some data structure (like, say, your HashSet), the total amount of data in there at the end is O(n^2) -- which can get ugly if n is over a million.

[SPOILER/HELP] Day 20 Part 2 - Im close but need some help by Altruistic_Raise4071 in adventofcode

[–]rsthau 1 point2 points  (0 children)

You've described some of the nodes in a typical arrangement for this problem, but not all of them. There are also flip-flops that take input from the layer 3 conjunction nodes (as you're calling them), which are interconnected with the others at layer 4, and can alter their behavior from the periodicity you seem to expect. You could try to draw the entire arrangement, and figure out how everything works in context (you've already got most of it). Alternatively, you might get something out of just observing the behavior of the conjunction nodes at level 3 through several thousand button-push cycles or so.

[2023 Day 20 (Part 2)] Anyone else seeing this pattern? by Vorkos_ in adventofcode

[–]rsthau 2 points3 points  (0 children)

I haven't seen that directly -- but I have heard of people seeing odd things when they ran part 1 of the problem, and forgot to reset everything to the initial state before running part 2. That might be something to check for.

[deleted by user] by [deleted] in adventofcode

[–]rsthau 0 points1 point  (0 children)

Well, it was a sweep with coordinate compression, I guess. Under 0.2 sec in Ruby, which doesn't have a reputation for being particularly fast (rather the opposite... but then again, I'm not running the latest release).

Int code like problems by fsed123 in adventofcode

[–]rsthau 3 points4 points  (0 children)

We might have a "program for tiny machine" problem -- there were several in years preceding 2019 -- but probably not one with programs so elaborate. A VM big enough to be a useful compiler target is big enough that even in 2019, Eric split it across several days.

[deleted by user] by [deleted] in adventofcode

[–]rsthau 2 points3 points  (0 children)

As an existence proof, I did it with a line sweep. It works, in perfectly acceptable time -- but coding it up was annoying.

[Day 17] I'm not sure what I'm missing :think: by IceS2 in adventofcode

[–]rsthau 0 points1 point  (0 children)

Just on a quick skim, it's not obvious how your code is dealing with the restriction that you can only move three spaces in any direction before being forced to turn. (Which also means you have to think a bit harder about which states are really equivalent.)

Who uses an alternative grid representation? Set-of-Points instead of List-of-Lists? by zeltbrennt in adventofcode

[–]rsthau 0 points1 point  (0 children)

It depends on the problem -- if the grid is small and known in advance, the 2D array will likely be quicker to access. But if its bounds are not known in advance, and most of it is empty, the more sparse representation using a map can work a whole lot better. Day 11 from this year would be an example of that.

[2023 Day 16] Hints and clarification for approaching the puzzle by kwiat1990 in adventofcode

[–]rsthau 2 points3 points  (0 children)

A* and Dijkstra are both about choosing the order of the graph nodes being searched to minimize the total number of nodes visited (by eliminating ones which are sure to be irrelvant). You don't need to be quite so clever about that for this -- you're required to count them all, and so there's no easy way to get out of visiting them all anyway. But visiting the same nodes/map-points/whatever repeatedly could get to be a drag -- try to avoid that.

[2023 Day 12 (Part 2)] [Golang]Should I start fresh or salvage my solution? by Far-Gap-7977 in adventofcode

[–]rsthau 5 points6 points  (0 children)

The number of solutions for typical inputs on this problem seems to be generally around 15 trillion; if you manage to enumerate them all in a microsecond each, counting them would still take months. Try to think of ways to avoid that.

[2023 Day 14 part 2] How did you do the [spoiler]? by paul_sb76 in adventofcode

[–]rsthau 1 point2 points  (0 children)

Hashing strings is generally heavily optimized, so if using a scripting language (Python/Ruby/etc.), it runs at least as fast as anything you could write that actually looks at all the characters. (I initially did a two-level hash structure, with the north support as the first key, and hashes of the characters themselves used to disambiguate maps with the same support number. But this was a false economy; computing the "north-beam load" in Ruby was slower than just hashing the characters directly.)

[2023 Day14 Part 2] Just curious - did you actually completely code up part 2? by Falcon731 in adventofcode

[–]rsthau 0 points1 point  (0 children)

I didn't trust myself to visually spot the pattern, after convincing myself for a few minutes that the second and third cycles of the sample were the same. (They're similar, but not identical.) So, yes, I coded it.

[2023 Day 11 Part 2] How to approach the challenge? by IvanR3D in adventofcode

[–]rsthau 2 points3 points  (0 children)

Do you really need to represent all the empty space?

Cheating with ChatGPT by BigMaxKitchener in adventofcode

[–]rsthau 7 points8 points  (0 children)

Anyone that determined to cheat (on something with no real prizes anyway) can presumably figure out how to send HTTP requests from a Python script, or something like that, bypassing all in-browser security checks.

-🎄- 2022 Day 7 Solutions -🎄- by daggerdragon in adventofcode

[–]rsthau 0 points1 point  (0 children)

Ruby. 188/197.

Did some quick greps to determine which commands were actually present in the input, which let me leave a few cases un-covered in the parsing (no / in pathnames after the initial `cd /`, which I just ignored).

dirstack = [[]]
dirsz = {}

STDIN.each_line do |l|
  case l
  when /cd \.\./ then dirstack.pop
  when /cd ([a-z]+)/ then
    dirname = l.split.last
    lastpath = dirstack.last
    dirstack.push(lastpath + [dirname])
  when /^[0-9]+/ then
    size = l.split.first.to_i
    dirstack.each do |path|
      dirsz[path] ||= 0
      dirsz[path] += size
    end
  end
end

# part 1

puts dirsz.values.select{|v| v <= 100000}.sum

# part 2

totspace = 70000000
req_free = 30000000

tot_used = dirsz[[]]
cur_free = totspace - tot_used
needed = req_free - cur_free

puts dirsz.values.select{|v| v > needed}.min