Beta

Coping with NP-Hardness #1: 2-SAT

10 of 13ALowVerus
Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • 4500zenja1 Avatar

    Alright, so I has been solving this kata for the huge amount of time, and all this time I had the error when I misunderstood one of the imporant aspects lol. Because of that, I spent about... 3 months on this kata, even though I was really close to the right answer? But still, I had a university study, and that error was completely on my side :s

    Apart of that, this kata is really good, I wish the issues with it would be cleared soon and it would get out of Beta :D

  • Blind4Basics Avatar

    (your description is a real nightmare.... :s )

    • what are exactly the inputs?
    • what are exactly the outputs?
    • info is spreaded all over the place (like NOT <=> -v given at the end while used in the very first lines)

    you should split it with some clear titles, to help you organize the "story" and your mind. For example: task / context / inputs / outputs / constraints (maybe context then task)

  • Unnamed Avatar

    Inconsistent performance requirements across languages: max 4x2 in Python vs 25+ lengths in Haskell.

  • JohanWiltink Avatar

    ( Haskell )

    evaluate [["a", "-a"]] `shouldBeElem` [Just ["a"], Just ["-a"]]
    

    Is this example test correct? I think Just [] would, or should, also be a correct answer.

    ( I haven't checked the submit tests. It's possible it's in there also. )

  • JohanWiltink Avatar

    It looks like the Python original uses a legacy Python version, a legacy testing framework, inadequate test headers, and very limited testing.

    Also, as suggested elsewhere, please mention in the description that variable names will always be single letters.

    There's a world to be gained there.

    Note that I don't speak Python, so some of the above may be just plain wrong. But I sincerely doubt all of it is.

    Depending on performance requirements, my estimated rating might be anything from 6 to 3. It'd be worth it to specify any such requirements, or lack thereof. That would make it easier to settle on a design before starting implementing.

  • JohanWiltink Avatar

    ( Haskell )

    Initial code is incorrect. module line should have where instead of with

  • Unnamed Avatar

    Haskell random tests:

    Falsifiable (after 2 tests): 
    expected: Just ["-x"]
     but got: Just ["x","-n"]
    [["-x","-n"]]
    
  • Unnamed Avatar

    Haskell: my solution passes the fixed tests, but fails at the random tests. There probably are some edge cases tests that should be added, but I'm not sure whether it's the reference solution or my solution that is incorrect and it's hard to tell when the random tests show the input in a different format: [Right (('f',False),('h',True))].

  • Unnamed Avatar

    Haskell: the tests should be made compatible with GHC 8.8.4.

  • PistachioCake Avatar

    Haskell translation submitted, please review and approve.

  • ChristianECooper Avatar

    Hi, I found a couple of issues:

    1. There's no explanation of what 2-CNF is, and the supplied link really doesn't clear anything up and uses notation that doers not tally with your examples.
    2. The last example test is not passable, as it checks identity rather than equality:
    res = sorted(is_satisfiable([['a'], ['b']]))
    test.expect(res is ['a', 'b'])
    

    Should be:

    res = sorted(is_satisfiable([['a'], ['b']]))
    test.expect(res == ['a', 'b'])
    

    A better link for the 2-CNF might be here. But even then that article uses the notation from predicate logic, which does not marry up with your implementation. So examples will still be needed.

  • Unnamed Avatar

    test.expect(is_satisfiable([['a']]) is ['a'])

    The sample tests are incorrect, there's no way to return the same object as the one that's going to be expected.