Ad
  • Custom User Avatar

    I think it really depends on your philosophy. Elixir doesn't have many idioms or strong suggestions as to how to go about a problem, so you see different approaches. For some, code being easy to reason about is more important than efficiency. I personally adhere to two things above efficiency:

    • datastructures should carry the majority of the complexity; algorithms should be clean.
    • No optimization before practical bottlenecks are identified at the expense of clarity.

    Other than that, I really appreciate this different take on the solution!

    Edit: I also like that this solution directly solves the problem and only the problem. Very nice.

  • Custom User Avatar

    This is the correct and clever solution. Not like all these collection generation brute force onces. I wonder why so much people mark not that good solutions as "clever" and "best practices". In most cases these algorithms are very complex despite on the fact that the code looks beautiful and easy. Ease != Simplicity.