Ad
  • Custom User Avatar

    A couple notes here.

    Number one, the naive way is MUCH more correct than this one. Most would just count left and right parens, and build the string with it. I choose to view this as a combinatorical problem with trees, and wound up not being able to finish it in time (mostly).

    Number two, randomized tests are simply bad design. By resubmitting over and over, I was able to avoid the two numbers (9 and 10) which would choke this admittedly over-complicated piece of code. It's probably better, especially with problems that (at least CAN) scale exponentially, to have a static set of test cases. Even more so when the max input it ever sees is 10.

    Third, while it's slow, inefficient, complex, and nearly impossible to read, this is one of my favorite pieces of code I've ever written.

    Thanks!

  • Custom User Avatar