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.
They don't.
The code you describe would return the first element of a list, while the solution above returns a list comprehension. In the later case, the whole list gets populated before the return statement executes.
Your described solution could come closer by using
yield
instead of return, except the return type would be a generator and not a list. Which means, for this to work you need a statement that would not interrupt the for-loop.See negation (arithmetic) among Python operators.
This is a list comprehension. It creates a new list while iterating over
lst
.Oh, nice!
Always found it boring to compile the pattern...
Thanks
@frenetic_be: I just translated this kata for Python, could you have a look?
Could I have any help about my issue instead of hidding my comment (while I do not remember giving any technical informations about a solution)?
I still get unexplained SIGSEGV error on the full test suite.
+1 for this idea, I would have upvoted your fork first :)
I support your suggestion on github.
Hi,
Thanks! It's better now.
Though I notices it could fail occasionally, going to refactor right now.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Hi,
There is a problem with basic test cases of this Kata in Python.
This test case: Test.assert_equals(mix("looping is fun but dangerous", "less dangerous than coding"), "1:ooo/1:uuu/1:ii/2:sss/2:aa/2:dd/2:ee/=:nnn/=:gg")_.
The expected solution is not right as I was stuck with is for testings but my solution worked with the final application.
BTW it is True that finishing this kata is more like resolving an enigma than just find the right implementation. Not sure is it really the point of CodeWars katas.
Hi,
Very weird issue here: I'm both printing and returning the answer to check whether my solution works OK, and for test case #3 it prints the answer 'e' which is correct, but I get error 'None should equal "e"'.
Even using a dirty fix to pass by, I get a similar issue in the following test cases when trying to apply my solution.
Can't figure how the interpreter could print a variable's value as a string in one line, then return it as None the line rigth after...
Any thoughs?
This comment is hidden because it contains spoiler information about the solution