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.
I don't remember this kata at all, but I see lots of other similar solutions... I'm not sure how I came up with this.
Can you describe the solution?
The first one takes care of molecules like this: Cl2. What it does is repeat the molecule x times. So Cl2 becomes ClCl.
The second one takes care of molecules with braces with a number after them. E.g. (CCHHHH)2 becomes CCHHHHCCHHHH. The third and fourth do the same but with [] and {} respectively.
The fifth one removes all left over braces as all braces that are left are guaranteed to have no number after them (so no repeating needed anymore).
The sixth one takes each atom and adds a space after it.
Then all the atoms can be split by splitting on a space, after which the reduce counts theatoms.
Its not fast but a funny one liner, though it is not perfect as nested braces don't seem to work (e.g. ((C2H6))2)
Can u explain reg exp ?
In start, store is not a number is undefined. Your store type should be number | undefined