Ad
  • Custom User Avatar
  • Custom User Avatar

    A bit late, but you can use something like a std::sync::atomic::AtomicU16 or just a static mut u16 as like a question counter, and then just return false when that counter hits a certain value.
    The only slight issue is that Rust tests are run in parallel, but I'm assuming only one of the test categories are timing out, so this should be fine.

  • Custom User Avatar

    I fixed it.

    Now, the order should no longer be predictable.

  • Custom User Avatar

    Fixed.
    I added the missing parentheses, now it should be correct.

  • Custom User Avatar

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

  • Custom User Avatar

    Is the to_string method correct?

    Star(
            Box::new(Alternative(
                Box::new(Terminal('a')),
                Box::new(Terminal('b'))
            ))
        )
    

    is printed as "a|b*", but surely it should be "(a|b)*"?

  • Custom User Avatar

    Yes, random tests sometimes generate weird regexes, but that is supposed to happen.

    If it is needed, I could simplify the regexes after generating it, but I don't think it is really needed. After all, the solution should work for any regex and while some of the generated regexes might look odd, they are still valid regexes that should be tested as well.

    To me, the fact that such regexes are generated by random tests is not a problem and it is supposed to happen.

  • Custom User Avatar

    Thanks for the suggestion! Unfortunately, this doesn't appear to work for me. I was previously writing to stderr unbuffered, but writing to stdout and flushing also appears to produce no output. (And to be clear, I'm writing the inputs out immediately upon the function call, not after doing any sort of processing.)

    I suspect there isn't much I can do here.

  • Custom User Avatar

    There are some unwieldly regex fragments being generated by the random tests, like e??* (which is just e*). Is this intended?

    (At least it's not generating something like e** as far as I can tell...)

  • Custom User Avatar

    I've passed all of the unit tests, but it appears that the random tests are timing out for me. AFAICT, there's no way to find out which specific test data is causing the timeout, right? I tried logging test cases to stderr, but it appears that when a test times out, Codewars just won't show the log for that test, unless I'm missing something. (When I explicitly fail a test, I do have the option to expand the log.)

    Certainly a fault of my algorithm, but it's hard to know what to benchmark without having solid examples (which are otherwise difficult to generate by hand). I'd love to be able to time profile a known failing test, because I really enjoyed working on this kata and I'd love to complete it.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    hhhh seriously which language is this now?

  • Custom User Avatar

    I recently watches a video where one guy explained this in details :D I'm amazed to see this again, gj :D

  • Custom User Avatar
    &['a', 'b', 'c'] == b"abc"
    
  • Loading more items...