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.
i write an O(n) solution. you can refer to it
You are right
It's the shortest, sure, but the best? If I saw this in production code I would be kinda miffed because the return function is indecipherable.
Added to description.
Which language is giving you trouble? Try logging your input. If you still cant figure it out paste your code as a comment with spoiler alert and someone will help.
Which language is giving you trouble? Try logging your input. If you still cant figure it out paste your code as a comment with spoiler alert and someone will help.
It seems that I passed the basic tests, but when I attempt to run the random tests as well, I pass the random ones and I've got an error:
Test Results:
Log
Great work!
Testing
Basic tests
expected 3 to equal 1
Should work for random tests
So I passed the random tests, but not the basic ones?
Maybe it is just me and I skipped something, but I would appreciate an explanation.
Thanks
This is, in my opinion, an inadequately constrained kata. It never explicitly states that the order of the face (eyes, nose, face) elements will always be the same, you just have to infer it from the test data.
How does
std::sort
compare pairs? Only the second element? Inserting into a vector however is not optimal. Why don't you just use the originalstd::vector
and overwrite those positions from yourevens
?This kata is obviously written by someone whose's not well-versed in English. Skipping this one.
I definitely wouldn't qualify this as "best practices" since it's creating an entirely new string
n
times (viastd::accumulate
). This is an O(k * n) solution, when it should be O(n). For high values ofn
andk
this is going to be sluggish.