#x 0s, y 1s, and z 2s

13 messages · Page 1 of 1 (latest)

frosty oreBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

patent trellis
#

Do you already have checks like "When biggest number > sum of 2 smallest numbers * 2 + 2 there is no such string"?

#

Pretty sure the math approach is better.

#

Usually in these problems there is a math trick you need to know.

#

The other thing you can do is make up test cases and try to find a failing test.

#

Try 1 2 8 maybe

#

Once you have a failing test you can track down what is going wrong.

#
for (int x = 1; x < 100; x++) {
  for (int y = x; y < 100; y++) {
    for (int z = y; z < 100; z++) {
      const bool should_succeed = z > (x + y) * 2 + 2;
      const bool actually_succeeded = makeString(x, y, z)[0] != 'N';
      if (should_succeed != actually_succeeded) {
        std::cout << "Failed for case " << x << ' ' << y << ' ' << z << '\n';
      }
    }
  }
}

Maybe this helps. You can also extend it to check whether the string is valid by counting the characters and checking for tripples.

#

Also 0 0 0 might be worth testing.

#

Also check whether it's something dumb, like you returned "No such string", but "no such string" would have been correct.

#

Or missing whitespaces or something

frosty oreBOT
#

@vast sinew Has your question been resolved? If so, type !solved :)

frosty oreBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity