dmccraw

dmccraw

Still learning elixir but here is my repo:

https://github.com/dmccraw/AdventOfCode2017

0
Post #21
mitja

mitja

I also started playing with it and chose to do it in Elixir, so that I learn it a bit more. Here are my solutions:
https://github.com/MitjaBezensek/advent-of-code

I particularly like how the solution for Day 6 turned out so simple:
https://github.com/MitjaBezensek/advent-of-code/blob/master/advent6.exs

1
Post #22
petecorey

petecorey

Here’s my day 7 solution, and my day 8 solution.

I’m not super happy with my day 7 solution, but it works. I spent a lot of time wringing my hands trying to figure out the best way to construct a tree from a list of edges, but eventually just decided to use a Map of edges to model my solution.

That said, I did learn about Erlang’s digraph and digraph_utils modules, which are pretty awesome for building a tree backed by ETS.

1
Post #23
petecorey

petecorey

And here’s my day 9 solution. I feel like this problem was especially well suited to solving with Elixir.

0
Post #24
alex_k

alex_k

I really enjoyed day 10.

We’re a bunch of people at work doing it and three of us are trying to solve them as quickly as possible.

0
Post #25
sasajuric

sasajuric

Author of Elixir In Action

I had fun with day 9, implementing a quick/dirty ad-hoc parser combinator. I feel this helped me clearly describe the input grammar.

0
Post #26
NobbZ

NobbZ

Sounds like fun :wink: I did actually just use a stack based FSM with 3 states (:init, :garbage and :group) and 2 symbols on the stack (:group and bottom/⊥) to calculate the groups score, :init | ⊥ was used as initial state and as the acceptor. I cheated a bit though, and passed around the current depth as well as the overall score, those were basically sideeffects of the automaton…

For the second part I just used a simple 2 state FSM (with the count as “sideeffect” again). Since I didn’t see any dependency between the nesting of groups and the garbage count, I simply ignored the grouping and only scanned for garbage.

1
Post #27
NobbZ

NobbZ

Day 10 wanted us to implement a circular list, which we can not represent without some trickery in the BEAM. Even worse, we were required to slice and dice this circular list, while we had to remember where the start is, especially this last requirement made me cry and I had to think about 2 hours how to do it best, before I implemented it using a map from index to value and extracting the slice and Enum.into/2 back into the map.

Part 2 cost me another hour of debugging until I realised that I had forgotten to append the constant to the end of the input, but after that solution was instant.

PS: Also I had some weird results, because l |> Enum.with_index() |> Enum.into(%{}) isn’t quite as I wanted it to be :wink:

0
Post #28
sasajuric

sasajuric

Author of Elixir In Action

I did it without using a map, but I had to to the reverse shift at the end of each step. Here’s the crucial bit. I think I could have avoided that reverse shift by keeping each element as {original_pos, value}, but I was a bit lazy this morning :slight_smile:

1
Post #29
mitja

mitja

I had a lot of fun with the Day 9, and the solution turned out so simple in the end!

Until now I struggled the most with day 7. Well, not really struggled, but I think that the solution I came up with could be improved.

0
Post #30