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.
It is impossible to detect it. A function taking a const reference to an object can be changed to take an object by copy and the calling code has no way to tell, it will compile just as fine. On Codewars it's actually often the other way around: old C++ kata took
std::string/std::vectorby value, and we tend to update their initial code to take const references instead for better practice. If users need a copy, they can remove the reference anyways.I don't think someone should be allowed to just change the const arguments and modify it. Codewars shouldn't accept this.
This comment is hidden because it contains spoiler information about the solution
You forgot the unordered_map hehe, but it's a very elegant and optimized solution.
While this is clever, I wouldn't consider it a best practice. It extends the range of allowed inputs to values whose cubes exceed the range that can be represented by the output type
Quite similar to Trip Cost
To expand on this, any non zero value returns true, any zero returns false. This means you never need to check if something == 0 in your if statements, you can infer that if it is zero it will return false, and structure the program around that.
Here is the list of all current C++ metaprogramming kata. Most of them deal with general TMP and not restricted to tuples (although you can use tuples as a means to solve them). The only tuple-heavy one is this beta. It dives into tuples more than this task.
This is not enough imo. The description should be more explicit about what it allows (or disallows). For example,
charis explicitly excluded, but most solutions (including mine) also count any non-charintegral type likeboolandchar32_t, which aren't tested. Moreover, if an answer only hardcodesdoubleandint, are they not excluding other valid numeral types likestd::size_torlong? I'm not saying these types should be tested at all - but the description should upfront be clear that it is only testingintanddouble. It signals that the solver should not strive for total correctness, and should instead make assumptions. Sounds like overthinking, but solvers can't see the submission tests and so can't tell what assumptions are being implicitly made.Regular
sizeofshould be exempt from the restrictions. You can use it as a part of a valid answer. Onlysizeof...should be disabled.Can someone please explain me this piece of code? what is id?
That's true, but there is no better way to do it, short of resorting to a higher-precision floating-point type.
You forgot for double inprecision, basicly floating-point arithmetic, not a good idea.
This comment is hidden because it contains spoiler information about the solution
in test example 3.14 and 42 are equal to 45.14, this is clear, but i wonder where did 0.001 come from?
Loading more items...