Ad
  • Custom User Avatar

    That's what I've been doing! I said in my question that adding debug logging is exactly what I've been doing. But when I put debug logging in, the test changes, so that when I get code that should solve that problem, suddenly the problem to be solved is different and my code doesn't work. (I know this because the expected output is now completely different!)

  • Custom User Avatar

    Here are some suggestions:

    1. For the tests where you get the wrong answer, copy the input (print(input) in the beginning of your code) and the expected output value.

    2. On your computer, add debug code to find errors, step by step, sometimes line by line.

    3. Once done, get back to the tests, the number of passed tests should increase.

    4. With the remaining errors or the new ones, go to step 1.

    This is how I passed all the tests. Good luck!

  • Custom User Avatar

    Regex is overkill for anything.

    If it's a very simple parse, like this, you'll get better performance and code that's easier to read by just writing it out imperatively. If it's a complicated parse, you'll be less likely to run into bugs, and have code that's easier to read, by using a proper parser DSL such as ANTLR. Regex isn't particularly good at either case, and its complexlity is extremely high. The "now you have two problems" joke exists for a reason.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution