hades

joined 2 years ago
[–] [email protected] 26 points 2 days ago (1 children)

Bless the Maker and His water, bless the coming and going of Him.

[–] [email protected] 6 points 1 week ago

The most noticeable for me are privacy /ˈpɹɪv.ə.si/ and urinal /juːˈɹaɪnəl/. I can't say I feel any of them are right or wrong, though, it's just a bit of colour in the language.

[–] [email protected] 3 points 2 weeks ago

I haven't played a lot of them, but my favorite is Bridge Commander. I think it was super janky, but also very immersive, had actual voice lines by Brent Spiner and Patrick Stewart, and decent plot.

[–] [email protected] 3 points 3 months ago

any chance it's overheating? did you clean the vents and checked the fans?

[–] [email protected] 1 points 3 months ago (2 children)

That just makes sense -- the top-1k are competitive programmers, and today's puzzle had nothing to do with competitive programming :)

[–] [email protected] 3 points 3 months ago (1 children)

Feels like a really bad way to get the solution, though.

Does that come from an expectation that AoC is a programming challenge, where you typically are expected to come up with an implementation that works for all possible inputs? Because AoC is intentionally not that. Some tasks in AoC can/should be solved by hand, and I don't think you should feel bad about it :)

[–] [email protected] 4 points 3 months ago (1 children)

In my input (and I suppose in everyone else's too) the swaps only occurred within the adder subcircuit for a single bit. In general, however, the way the problem is phrased, any two outputs can be swapped, which can lead to two broken bits per swap (but this just doesn't happen).

[–] [email protected] 4 points 3 months ago (4 children)

Good, although it took some time. Actually, I got my personal best global rank on that problem.

[–] [email protected] 12 points 3 months ago

good start to your new collection of abstract art

[–] [email protected] 2 points 3 months ago (1 children)

Could you fix the year in the title? Will get confusing in four years :)

[–] [email protected] 3 points 3 months ago

C#

public class Day19 : Solver {
  private string[] designs;

  private class Node {
    public Dictionary<char, Node> Children = [];
    public bool Terminal = false;
  }

  private Node root;

  public void Presolve(string input) {
    List<string> lines = [.. input.Trim().Split("\n")];
    designs = lines[2..].ToArray();
    root = new();
    foreach (var pattern in lines[0].Split(", ")) {
      Node cur = root;
      foreach (char ch in pattern) {
        cur.Children.TryAdd(ch, new());
        cur = cur.Children[ch];
      }
      cur.Terminal = true;
    }
  }

  private long CountMatches(Node cur, Node root, string d) {
    if (d.Length == 0) return cur.Terminal ? 1 : 0;
    if (!cur.Children.TryGetValue(d[0], out var child)) return 0;
    return CountMatches(child, root, d[1..]) + (child.Terminal ? CountMatches(root, d[1..]) : 0);
  }

  private readonly Dictionary<string, long> cache = [];
  private long CountMatches(Node root, string d) {
    if (cache.TryGetValue(d, out var cached_match)) return cached_match;
    long match = CountMatches(root, root, d);
    cache[d] = match;
    return match;
  }

  public string SolveFirst() => designs.Where(d => CountMatches(root, d) > 0).Count().ToString();

  public string SolveSecond() => designs.Select(d => CountMatches(root, d)).Sum().ToString();
}
[–] [email protected] 2 points 3 months ago
  • A* algorithm
  • honestly a lot of other graph algorithms, just be aware of them, and be able to find algorithms you didn't know before
  • OEIS
  • SMT solvers
  • set operations on intervals
 
view more: next ›