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.
If you reread the descriptions of the different arguments to the function you should find that some include descriptions of what values are considered valid. This implies what most of the invalid cases are, and the rest are covered by the other part of that paragraph, about the function not being defined.
I'll tweak the wording to try to communicate it more clearly but the relevant error cases are given from the information in the description.
A good kata, but I feel like allowing this is a problem: https://www.codewars.com/kata/reviews/5e36ce74fc5a260001e64e2b/groups/5e47b5b54f4fe30001c2a5d8
Is there a specific reason you only test square arrays? I feel like it would make more sense if we had some tests which included non-square and even non-rectangular arrays.
Also, in the random tests, it's a bit weird to me to populate the entire array using the same value, and also that you only test the 3x3 case.
Very elegant solution as always, great job!
BF translation: https://www.codewars.com/kumite/5fb7419ea5d7b50008423ec6?sel=5fb7419ea5d7b50008423ec6
BF translation kumited: https://www.codewars.com/kumite/5fb62ceb1704d0000f4c929d?sel=5fb62ceb1704d0000f4c929d
Let's work through a sample input [[1,2], [3,4], [5,6]].
Think of it as a tree diagram: before we pick any elements we only have one possibility, which is that we've chosen nothing. Then, we can pick either a 1 or a 2 from the first sub-array, giving us 2 possible choices. Then, for each of those choices, we can now pick a 3 or a 4 from the next sub-array, which gives us 2 new choices for each choice we had before. So now we should have 4 possible choices, and then when we pick from the third sub-array, again we have that each choice should yield 2 new choices, giving us 4 * 2 = 8 total choices.
So the trick is, every time we pick from a new sub-array, our number of choices gets multiplied by the number of unique elements in that sub-array.
The only remaining trick in this implementation is the use of set, which turns a list into a set containing all of its unique elements, with no duplicates. This is why this implementation works even when there are duplicates in the sub-arrays.
Doesn't this run into problems if a string longer than the tape length is passed in?
This comment is hidden because it contains spoiler information about the solution
Yeah I waaaaaay overcomplicated it :P
Nice kata! I really like the mathematical aspect of it, the math-centric problem-solving I needed for my solution was a lot deeper than I thought at first.
(probably because I missed something obvious but whatever)
Quick note, I already made the switch but you were still importing the preloaded evaluation function from preloaded, which was causing some silliness where we could just overwrite the evaluation function to make it always 1.
This comment is hidden because it contains spoiler information about the solution
Yeah ballot is just a string here, it's mentioned in the code snippet in the description. So .lower() is just Python's lowercase method.
Fair enough
Loading more items...