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
Thank you for this info.
If you want, you can do this in one line
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
Beware! You should not convert unknown strings to atoms. Atoms are not garbage collected, so you could end with a memory leak or a security vulnerability
FYI - You can split using a regex rather than doing a replace + split.