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.
Hey gang, just wanted to give some quick context. This was something we posted for a hackathon we did at work. The goal was to come up with the slowest possible solution that would still pass the test cases. We wanted to have something atypical, so a competition to find the worst possible solution let us be creative and have some fun.
OK, I'm running with it then.
Thanks. ( Hope it helps. :)
I like it.
How's the next fork? I replicated as much of the text as possible.
I think this one is clearer than the current one, I'd use this one.
I guess it's down to syntax. ( And then implementation * 6 .. some in languages I don't speak :[ )
Check the next fork then. What I didn't like from that error message, was that it was showing different data types, but as you want to show there can be different correct answers, maybe it's the way to go.
that's not so bad, is it?
prepend "testing
[ possible correct indices ]
includesreturned index
:" to it?So if user returns an incorrect index, you generate a correct one and show that as the expected value.
In all honesty, I don't want to do that. It misrepresents there can be multiple correct ansers.
A solution might be to just do the testing completely outside of the framework and just do an
assert.fail
on mismatch - that doesn't need to generate a framework failure message, so I can completely customise the failure message.Yours works for arrays of numbers. Mine works for any array that has elements of a single datatype in it.
It's not more accurate, it's more general.
Thank's for the tip, I did not know Math.min is more efficient than sort in this context. Although it does make sense on further thought.
Just curious, why is your sort function more accurate than the more mainstream version in my solution?
Yep, that's one way.
My personal favourite is
.sort( (x,y) => Number(x>y) - Number(x<y) )
which always works ( for array elements all of the same type ).Note that
Math.min
is more efficient for finding a minimum thansort()[0]
.Unless the lesson you learn is that sometimes there is an easier path.
very beautiful solution
I agree, I was able to pass the tests without fully functional code
Loading more items...