5 kyu

The longest bracket substring in the string

150 of 345myjinxin2015
Description
Loading description...
Puzzles
Performance
Algorithms
  • Please sign in or sign up to leave a comment.
  • artem-totality Avatar

    Unexpectedly hard task, like for 5 kyu. I spent two days, before I solved it. Really good job)))

  • johnbrooksby Avatar

    In your example in the details, why is "())(()))" supposed to return 4? That looks like 6 to me ( reduces to "()(())" ). Are double sets (()) not counted as two sets (4 characters)?

    • rowcased Avatar
      AFAIK:
      "())(()))" the case at hand
      "())  (()))" seperated into contained groups
      so the second group has a length of 4
      
    • Awesome A.D. Avatar

      I don't know what you mean by "reduces to", but this:

      ())(()))
         ^^^^ 
      

      is the longest balanced bracket substring. Whereas ()(()) is not even a substring of the given string.

    • johnbrooksby Avatar

      Thanks, I get it now. Boy was I barking up the wrong tree here

  • Awesome A.D. Avatar

    Python translation updated with new test framework

  • Awesome A.D. Avatar

    Rust translation ready for review.

  • RNOH Avatar

    nice kata!

  • wickedposh Avatar

    hello I am stuck with this kata somehow. Ive got 20 wrong out of 160 tests, and I cannot think of the cases when my code doesnt work. so if possible could you give me more basic tests to work out?

  • lechevalier Avatar

    Many linear solutions in python 3 can't pass tests if they aren't exactly the same as referee solution. Micro optimization is evil. I suggest to lower number of tests a little to accept more variations.

    • myjinxin2015 Avatar

      Many linear solutions in python 3 can't pass tests if they aren't exactly the same as referee solution.

      I don't know what this means. Sometimes, referee solution's result is wrong? Or..

    • cliffstamp Avatar

      I think he means a solution which runs in linear time still fails .

    • lechevalier Avatar

      Thanks @cliffstamp, that's exactly what I mean.

      Due to number of tests, difference between execution time and time limit is very tight - at the moment only one set of instructions pass test suite in Python. However I assume purpose of test suite is to assert that player's solution runs in linear time. So lowering number of tests a bit might be wise to not prevent good solutions to pass tests.

    • FArekkusu Avatar

      Sounds like an issue to me...

      Execution speed should be checked with tests which solutions with bad time complexity cannot pass, not by running lots of tests while imposing tight time limits. Unless it's a micro-optimization task, though the description doesn't says so anywhere.

      In fact, the description doesn't even mention the performance requirements of the Python version.

    • lechevalier Avatar

      It did mention performance requirements for all versions and yes micro-optimization is also an issue in my view but let's hear what myjinxin thinks about it.

    • myjinxin2015 Avatar

      Reduced the number of testcases in the performance tests to 50. When I test with the translator's solution, I often get timeouts, too. So, It's obviously too strict with users ;-)

      Suggestion marked resolved by myjinxin2015 6 years ago
  • KenKamau Avatar

    Python translation

    Please review and approve.