HackerRank Bugs

Programming-quiz site bugs

The programming-quiz websites are all the rage nowadays, and I get it.

But it’s a wee bit frustrating when, during a timed challenge, you discover what may be an issue with the website itself. Then you have to troubleshoot it. Then you have to work around it. Did I mentioned that this is a timed challenge and the clock is ticking?!

So as a little balm to my frustrations, here are some bugs I’m finding as I go.

Maybe I should mention, too, that while I’ve never found a bug with a C compiler, I’ve found bugs in every C++ compiler I’ve ever worked with.

I’m glad to modify these or remove them from my website. Just contact me to discuss.

HackerRank’s C++20 environment is missing unordered_map<>::contains()

As of Sept 15, 2023.

HackerRank’s C++20 environment is missing std::unorderd_map<>::contains().

This should compile:

Missing contains() – source code

But instead it gives:

Missing contains() – compiler output

Of course you can write your own with:

   bool contains(auto &container, auto const &key)
	  return (container.find(key) != container.end());

It’s probably missing all these, as they’re all a bit newer in terms of the C++ language:

  • std::unordered_set<>::contains()
  • std::set<>::contains()
  • std::map<>::contains()

HackerRank’s code editor template is broken for C++20

As of June 5, 2024.

HackerRank’s inherited code challenge: the problem statement makes reference to the locked section of your editor. But where is that? For C++20, it’s not there. Instead, you find a simple main() template, with all the crucial code missing.

Switch to C++11 or C++14 instead. Or if you want to go a little rogue, copy the code template from the C++14 editor to the C++20 editor and go from there. It doesn’t preserve the locked section, but the code is there and typically works. (Wouldn’t you rather use C++20 anyway?)

Update: Numerous other challenges have this same issue.

When a new compiler is introduced, does HackerRank need to add every such template manually?

HackerRank inconsistent timeouts

I work a hard problem, and get all the test cases generating the right output.

But I’m still getting Time limit exceeded for a few. And, when I re-run, the particular test cases change! So each run, one to three test cases fail this way, but eventually I see each test case pass at least once. So I keep retrying and eventually all tests succeed and I get full credit.


HackerRank template code generates ten compile warnings

Ten compiler warnings in the provided template code (provided at the start of the exercise), and which you cannot (and should not) edit. Pretty sure this isn’t a deliberate part of the exercise.