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.
coolest
That's a great observation! Thanks for posting it.
This code doesn't work when given string has a single upper case letter.
to_underscore('JustATest')
The regex picks any character followed by an uppercase letter and sets two groups
\1 = [any character]
\2 = [the uppercase letter that follows]
Then it replaces this pattern by the format "\1_\2"
So, for the string 'CodeWarsPascalCase' it will pick 'eW', 'rP' and 'lC' and replace with the new given pattern ('e_W', 'r_P' and 'l_C')
Pretty clever, indeed.
Am I correct in saying that the \1 and \2 sub in the first and second mathes?
BTW, I used re.sub("(?<=.)(?=[A-Z])","_",str(string)).lower() as shown here: http://www.codewars.com/kata/reviews/5463c85a372ca866430000d4/groups/55ba30c61f97ea5c82000061 for my Regex.
Very clever, thanks for the explanation!
I wouldn't come my dict dict. Otherwise clean.
Now, see kids? This is how Satan codes.
By pulling the max out of the list comprehension you'd be running through it only twice and making the code shorter ;)