Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
As far as I understand how Elixir works, using Map makes the code DRYer, but it doesn't leverage Elixir and BEAM optimization process.
With
@p1_wins_table[p1]
Map is accessed during runtime, wheredef ("scissors"), do:...
are optimized during compilation and there's no need to lookup for proper values in the Map on runtime. For the sake of this kata, this may seem irrelevant but may play a significant role in real-world use cases.More info: https://medium.com/@amuino/maps-vs-pattern-matching-in-elixir-e69b7bb11b5d
Would be DRYer to use a Map instead of defining 3 helper functions
This comment is hidden because it contains spoiler information about the solution
This results in O(n^2) time because of the nested loop of length n * (n-1); the optimal solution is O(n) time.