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.
Please correct me if I am wrong, but I don't think it is possible for me to add a Python solution to a pre-existing kata. If there were a way to merge this kata with the one referenced above I probably wouldn't be opposed.
As I write this there are only 13 kata availible in Python. Just trying to expand the Python offerings.
I think python is far too dynamic for any kind of static analysis to catch this kind of trickery.
I expect that it is possible to outwit the code above, but if it is wrapped up in a nice API for us to use it should be relatively easy to plug any holes as they are found.
Clever hack :)
At the risk of playing whack-a-mole I have blocked that workaround:
It would be nice if there was an easy/standard way for kata authors to block access to certain library functions...
The referenced kata is a Javascript only, and thus not a duplicate of this Python only kata.
Additionaly this kata is meant to excercise some specific Python features (generators) and pitfalls (lists are passed by reference - be aware of side-efects when modifying them).
@cmgerber:
Your itertools solution fails because the function returns an iterator rather than a generator. All generators are iterators, but not all iterators are generators.
I have updated the description of the kata to emphasize this.
I have also disabled itertools.permutations as it makes the kata too easy :)
@xcthulhu:
the permutations function only needs to take one argument - the 2nd argument being passed was a bug which has since been corrected.
There was a bug in the validation routine.
I have published a new version. Give it a try.
Much better.
This solution certainly solves the kata.
I only commented because this solution has a number of "best practices" votes.
Per the kata description:
"...a function that takes in a list and returns a list with the revese order."
In a function with that description modifying the passed in list is not "best practices"
If I could cast a down vote for "best practices" I would have done that instead of leaving a comment.
The description of the python version is not very good.
As rmunn mentions the API is not specified.
It should be noted in the description that add and subtract should return new vectors (as aposed to modifying the object in place).
"norms" needs to be defined.
I propose that the description of the python version of this kata be changed to the following:
Description:
Create a Vector class that supports addition, subtraction, dot products, and norms.
The Vector class should support the following methods:
If you try to add, subtract, or dot two vectors with different lengths, you must throw an error!
The test cases will utilize the user-provided equals method.
This one has the side effect of modifying the passed in list.
I would be much better to copy the list before reversing it.
Need to explain that the report object is a mutable object that updates as new calls are made.