Andrew Fontaine

Mostly code

More intcode computing! Without any modifications to the computer, and a quick search for an algorithm to make permutations, which, like, I just didn’t want to have to figure out, and I am ready to solve this.

  defp permutations([]), do: [[]]

  defp permutations(list),
    do: for(elem <- list, rest <- permutations(list -- [elem]), do: [elem | rest])

Once my permutations are generated, all that’s left is to amp things up.

Read more.

Today, I’m pretty much playing Kerbal Space Program and planning some orbital trajectories. As shown in the problem itself, a tree is the perfect way to represent the orbits, so building one shouldn’t be too hard.

  defp build_tree([], node), do: node

  defp build_tree(list, p) do
    connections = Enum.filter(list, &String.starts_with?(&1, p))

    list = Enum.filter(list, fn x -> x not in connections end)

    c =
      connections
      |> Enum.map(fn x -> x |> String.split(")") |> List.last() end)
      |> Enum.map(fn x -> build_tree(list, x) end)

    %{p: p, children: c}
  end

list here is the list of connections I’m given, in the form of AAA)BBB, and p is the object that I am finding satellites of. First, I find all the connections by filtering the list for lines that start with the payload, and then for each child I build a tree with that child as the root. Once all the lines are filtered out, the tree is complete.

Read more.

In which previous bad code shoots me in the foot.

This was a continuation of the puzzle from day 2. If you don’t recall, I made a small intcode computer that was able to add, multiply, and stop. I need to augment this computer by adding the ability to take input and produce output. I also need to handle “parameter modes” and expanded intcodes

Read more.

This one didn’t seem too bad, but I can’t help but feel there’s a “clever” solution that alludes me. Some sort of funky math theorizing that I just don’t know about.

Puzzle 1

Put on your hacker gloves, it’s time to crack some passwords!

Read more.

After 3 puzzles, I am taking a look at how things are set up, and making a few tweaks.

Projections

My projections just do not work. It gets confused when trying to call :A on a test file, going to or making a source file instead of jumping to the appropriate puzzle file. To alleviate this, I needed to make some alterations:

Read more.
Older Newer