Recently I had an interesting interaction on one of my questions. A user posted this answer in C++. My question requires a function on the positive numbers that has some properties, the user's answer essentially implemented the function add 1
, which does not satisfy these properties on the positive integers, however this function does satisfy these properties on a cyclic group, which C++'s unsigned
type is (this actually not define as such in the C++ specification, however almost all implementations do it this way).
Needless to say I have asked the user to delete the answer and the obliged. However this brings me some concern. In order to "fix" their answer it seems that this user would have to implement their own dynamically allocated integer class, which is a big pain to do (believe me I've done it before). It feels to me as if this is overkill, we often allow answers that will occasionally calculate an incorrect, as long as the "algorithm" is correct.
What should I do in this case? Is there a way that answers in languages like C++ can reasonably compete on these types of challenges without "cheating"?
Is there a way that answers in languages like C++ can reasonably compete on these types of challenges without "cheating"?
How would they implement it differently than the JavaScript answer, for example, which will have incorrect behavior at some point? \$\endgroup\$INT_MIN
toINT_MAX
in the language, if it does not have arbitrary length integers? \$\endgroup\$+1
on that range and complicated every where else (if you want to know this function ping me in chat and I'll explain), thus someone could implement+1
and claim that they are implementing that function. It would work just like the function on the range int min to max, but that would be the trivial portion of the function. \$\endgroup\$