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.
This comment is hidden because it contains spoiler information about the solution
Fairly new to regex myself. I wondered the same after reading your comment and found this SE thread very informative.
http://programmers.stackexchange.com/questions/113237/when-you-should-not-use-regular-expressions
Never mind - set comprehension! Duh!
how does this pass the test case where there is a duplicate in the input list? I don't see how this comprehension eliminates repeating elements...
eg:
a1 = ['a','a',b']
a2 = ['ha', 'ba']
why is the output NOT ['a','a','b']?
I see that almost all the solutions are Regex based. I have heard that regex should be avoided unless there is a very strong reason to use it. Here, the regex is simple and quite easy to get right but I'm wondering why we WOULD or WOULD_NOT choose a regex in the wild
The input may have 0's in unexpected places - try making the ranges 0-9 and see if that is the issue...
Good point - I had not conisdered the "N times" instruction. That would be very hard to accomplish with a zero lenght string!
Thank you, this function really doesn't work in this case. However, there is the following statement
in the task: "reverse function should be executed only N times", so this case is impossibe, but thank you again, I changed my solution.
I see this failing for a zero length string so this not be one of the test cases. Fix it simply...
return str if len(str) <= 1 else str[-1]+reverse(str[:-1])