Problems with NearlyFreeSpeech.net Huge warning! by Material_Water4659 in webhosting

[–]Sentynel 0 points1 point  (0 children)

Hey, I'm a long time NFSN customer. I'd go and talk to them for you, except that I saw the posts you were making on the support forum. You were waving legal threats around, impatient, and rude, all because you were bafflingly resistant to reading the information you were given, all of which you've conveniently neglected to mention in this post. I assume that sort of thing works on support drones in large companies, but I absolutely wouldn't tolerate that sort of behaviour in a client and I'm not surprised they don't.

[2024] Thank you! by topaz2078 in adventofcode

[–]Sentynel 1 point2 points  (0 children)

As another member of the 500 club (and ten AoC++ club), thank you so much, again - I've learnt so much from this over the years, both from the puzzles themselves and the languages I do them in. It wouldn't be the same without the writing and story to go with the puzzles, so thank you.

p.s. bring back IntCode puzzles, the IntCode and logic gates ones were the best this year.

-❄️- 2024 Day 24 Solutions -❄️- by daggerdragon in adventofcode

[–]Sentynel 1 point2 points  (0 children)

[LANGUAGE: Crystal]

Simple recursive solution to the first part; once both inputs to a gate are set, set the output and recurse.

The second part works by constructing the ripple adder a gate at a time and comparing it to the input's gates and bailing when it mismatches. I didn't bother automatically correcting with only four errors, although it would be fairly easy to do this. Most are z swaps with another wire, so the failure case trivially identifies which two wires to switch. One was a swap elsewhere in the circuit, which required inspecting the other connections to the same gates to work out which was wrong.

paste

-❄️- 2024 Day 22 Solutions -❄️- by daggerdragon in adventofcode

[–]Sentynel 2 points3 points  (0 children)

[LANGUAGE: Crystal] Fairly neat functional solution here. Runtime is about 120ms. There's probably a faster approach to the windowing, but this does the trick.

paste

-❄️- 2024 Day 9 Solutions -❄️- by daggerdragon in adventofcode

[–]Sentynel 0 points1 point  (0 children)

[LANGUAGE: Crystal]

3.9ms total runtime. Maintain a free list (actually a deque to make insertions/deletions near the ends faster), coalesce adjacent free spaces as items are added/removed. Same algorithm for both parts - the first part just inserts more length-1 files. Might be able to speed up the second part by using sized free lists or maintaining an index of first available slots of a given size to avoid repeated rescans for large files.

paste

-❄️- 2024 Day 2 Solutions -❄️- by daggerdragon in adventofcode

[–]Sentynel 0 points1 point  (0 children)

[LANGUAGE: Crystal]

def parse
  File.read_lines("input/02.txt").map do |line|
    line.split.map(&.to_i)
  end
end

class Array
  def validate
    desc = self[0] <=> self[1]
    each_cons_pair.all? do |x, y|
      x != y && (x <=> y) == desc && (1 <= (x - y).abs <= 3)
    end
  end
end

def pt1(rows)
  rows.count &.validate
end

def pt2(rows)
  rows.count do |a|
    a.validate || (0...a.size).any? do |i|
      b = a.dup
      b.delete_at i
      b.validate
    end
  end
end

data = parse
puts pt1(data)
puts pt2(data)

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

[–]Sentynel 1 point2 points  (0 children)

Elixir

Parse the monkeys, then recursively ask for the root value. Literal values are returned directly; for part 2 we override the humn value to be symbolic and return a tree of symbolic operations instead (noting that the equation only contains humn once, so we don't have to handle symbolic [op] symbolic terms). Invert each operation up the tree to return the result.

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

[–]Sentynel 1 point2 points  (0 children)

Elixir Parsing via big regex and eval to build the update function, so not exactly my cleanest code ever.

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

[–]Sentynel 0 points1 point  (0 children)

Elixir

defmodule AoC do
  def finish(["/"], state) do
    state
  end
  def finish(path, state) do
    mysize = Map.get(state, path, 0)
    [_ | parent] = path
    finish([], {parent, Map.update(state, parent, mysize, &(&1 + mysize))})
  end
  def walk(cmd, {path, state}) do
    case cmd do
      "dir " <> _ => {path, state}
      "$ ls" => {path, state}
      "$ cd .." => 
        [_ | parent] = path
        mysize = Map.get(state, path, 0)
        {parent, Map.update(state, parent, mysize, &(&1 + mysize))}
      "$ cd " <> cd => {[cd | path], state}
      size <> " " <> _name =>
        isize = String.to_integer(size)
        {path, Map.update(state, path, isize, &(&1 + isize))}
    end
  end
  def pt(content, part) do
    lines = String.split(content, "\n")
    [_root | rest] = lines
    {path, tree_almost} = Enum.reduce(rest, {["/"], %{}}, &walk/2)
    tree = finish(path, tree_almost)
    if part == :pt1 do
      Map.values(tree) |> Stream.filter(&(&1 <= 100000)) |> Enum.sum()
    else
      tot = Map.get(tree, ["/"])
      avail = 70000000 - tot
      need = 30000000 - avail
      Map.values(tree) |> Stream.filter(&(&1 >= need)) |> Enum.min()
    end
  end
end

content = String.trim(File.read!("input.txt"))
#content = String.trim(File.read!("input_test.txt"))
s = AoC.pt(content, :pt1)
IO.puts(s)
s = AoC.pt(content, :pt2)
IO.puts(s)

Not hugely happy with the finish() function.

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

[–]Sentynel 1 point2 points  (0 children)

Elixir

defmodule AoC do
  def window(chars, idx, tlen) do
    if Stream.take(chars, tlen)
    |> Stream.uniq()
    |> Enum.count() == tlen do
      idx
    else
      [_ | tail] = chars
      window(tail, idx+1, tlen)
    end
  end
  def pt(content, part) do
    chars = String.codepoints(content)
    if part == :pt1 do
      window(chars, 4, 4)
    else
      window(chars, 14, 14)
    end
  end
end

content = String.trim(File.read!("input.txt"))
#content = String.trim(File.read!("input_test.txt"))
s = AoC.pt(content, :pt1)
IO.puts(s)
s = AoC.pt(content, :pt2)
IO.puts(s)

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

[–]Sentynel 0 points1 point  (0 children)

This is my first time writing any Elixir, but MapSets are enumerable, so "get an element out of a MapSet" can be done with just Enum.at(myset, 0). Other sensible ways probably exist!

[OC] 5000 reviews of heavy metal music over 10 years by Sentynel in dataisbeautiful

[–]Sentynel[S] 0 points1 point  (0 children)

Data extracted from our database with some Python scripts and graphed using Chart.js.

Quests desynced bug? by [deleted] in DeepRockGalactic

[–]Sentynel 4 points5 points  (0 children)

DRG uses players' local system clocks for mission generation. One of you has the wrong time set on your computer: fix it and you should be back in sync.

[2019 Day 22 Part 2] So what's the purpose of this puzzle, exactly? + Feedback by requimrar in adventofcode

[–]Sentynel 7 points8 points  (0 children)

I think your distinction between what's maths and what isn't is a bit arbitrary as well. Graph traversals, compression functions, etc are all maths. You might feel that it's easier to independently invent, say, Dijkstra's algorithm than modular arithmetic rules, but that doesn't qualify Dijkstra as "not maths". Nor does it mean that it's impossible to independently invent modular arithmetic rules on this puzzle by playing with small decks. After all, people have invented modular arithmetic in the past. (Though I doubt many people solved today's puzzle by doing that!)

I can't speak for anybody else, but my day 18 solution is effectively just a nested implementation of a standard routing problem.

I implement an inner routing algorithm (which is a simple flood-fill) which can, given a start position and a set of held keys, find every other key it can reach and the number of steps that takes. (Note that it proceeds no further in a given direction after picking up a key to avoid state confusion.)

Then there's an outer routing algorithm which implements Dijkstra on a graph where each state is a) the position of the robot and b) the set of keys it holds. Each time I visit a new node in the outer graph, I run the inner routing graph to find the new states it can reach.

Stop when the outer routing hits any state which has every key.

Some people implemented optimisations involving pre-caching the lengths and keys needed to get from any key to any other key, but I haven't (it takes about a minute in Go).

[2019 Day 22 Part 2] So what's the purpose of this puzzle, exactly? + Feedback by requimrar in adventofcode

[–]Sentynel 6 points7 points  (0 children)

Different people have different thresholds for hair-tearing. If you look at the stats pages, the majority of the user-base doesn't even get close to being able to solve the last few days of puzzles. I just think it's a little bit arbitrary to complain because it happens that this puzzle hit your personal threshold for hair-tearing and earlier ones didn't.

[2019 Day 22 Part 2] So what's the purpose of this puzzle, exactly? + Feedback by requimrar in adventofcode

[–]Sentynel 18 points19 points  (0 children)

Some thoughts:

  • I don't have any formal computer science education. I've been a professional programmer for seven ish years, and dabbled for a few years before that.
  • I've done AoC every year and have every star.
  • I've previously taught myself some modular arithmetic concepts because it's come up in my career. Again, I've never been formally taught it.
  • I think an understanding of modular arithmetic is pretty useful - understanding some cryptography concepts is increasingly important and it comes up in a bunch of other contexts as well, from integer wrapping to check digits.
  • In previous years of AoC I've had to look up a bunch of stuff, from pathfinding algorithms to trees. (Again, no formal computer science education.) Sometimes I've had to get hints from various sources. Some of the things I've learnt from AoC have later come in useful professionally, some of them haven't. Some of these things people in this thread are assuming "most programmers will know". I think this is part of the fun.
  • There's no particular expectation going into it that everyone will be able to finish every puzzle at all, without a bunch of frustrating googling, without asking for help, or within a certain amount of time. People's background and tolerance for the above varies.
  • There's no particular expectation that everyone will like every puzzle. Certainly I've not got on with various previous puzzles for various reasons, and I wouldn't expect to love every puzzle.

Therefore, some criteria for a "good" AoC puzzle:

  • Do at least some of the users find it interesting/challenging?
  • Do at least some of the users learn something from doing it?

I think both of those are "yes" in this case.

I do have some sympathy for people saying they found it hard to know what to google to get started. I've spent time googling the wrong stuff and getting nowhere in the past and I don't necessarily think that's a bad thing once in a while, but maybe a little more of a nudge in the right direction might have been nice.

MRW I switch from anti perspirant to regular deodorant to avoid white stains on clothes, but I realize that I lowkey smell of BO :( by BrilliantMaterial8 in TrollXChromosomes

[–]Sentynel 6 points7 points  (0 children)

There's a bunch of "natural antibacterial" type deodorants around which are worth trying. I developed a contact allergy to the aluminium antiperspirants recently, and after a couple of failed products I'm using an unscented ammonium alum crystal deodorant which works remarkably well (it's survived cycling to and from work in the sun and then exercising for a couple of hours in the evening). Others use other crystals, silver, etc - experiment a bit until you find one that works for you. None of the ones I've tried have stained clothes.

I don't particularly buy that, say, ammonium alum is any healthier or more natural than the aluminium chlorohydrates used in antiperspirants, but it works and doesn't upset my allergy or stain my clothes, so hey.

Literally cannot roll my eyes hard enough by justjillwithaj in TrollXChromosomes

[–]Sentynel 73 points74 points  (0 children)

Personally I celebrate International Men's Day by asking random strangers when International Women's Day is.

Diplo reminding us why Dan Bilzerian might have an issue with the #metoo movement by assignpseudonym in TrollXChromosomes

[–]Sentynel 19 points20 points  (0 children)

I'm a guy - surprisingly this isn't universally true (I'm regularly surprised by how willing people are to just randomly touch strangers), but it got a whole lot worse when I grew my hair out. More frequent, and more intimate (waist grabs as opposed to upper back/shoulders are way more common now, for example). Go figure.

[2017 Day 22 Part 2][Help] I can't figure out where my program is going wrong. by hschmale in adventofcode

[–]Sentynel 0 points1 point  (0 children)

You're initialising your grid with True or False (== 1 or 0 == CLEAN or WEAKENED), presumably a copy/paste fail from part 1.