5 kyu

Mistaking a forest for a tree

Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • saudiGuy Avatar

    python: function name should be snake_case

  • Awesome A.D. Avatar

    Note that if node 0 is connected to node 1, node 1 is also connected to node 0. This will always be true.

    This is not always true. In fact, from the sample tests:

                                          |¯¯¯¯¯¯¯¯¯| where is 1?
                                          v         v
    test.assert_equals(isTree([[1,2,3],[0,2],[1,2],[0]]), False)
                                  ^           ^^^
                                  |____________| where is 0?
    

    The wording is either misleading (if such a case needs to be checked) or otherwise plain wrong.

  • Voile Avatar

    The current top solution still doesn't account for more than one connected components, and it only fails random tests very occasionally.

    Shouldn't tests like [[1,2],[0,2],[0,1],[]] be put on the fixed tests?

  • monobrawl Avatar

    This comment has been hidden.

  • marbiru Avatar

    This comment has been hidden.

  • Blind4Basics Avatar

    Hi,

    Don't resolve to fast: about random tests, that's not enough. ;)

    • increase the number of tests to 100
    • it seems that your random generator when it doesn't create a tree, creates only graphs with closed paths and never unconnected ones only (meaning, the condition that checks that all nodes have been traversed is always true).
  • think_tank_ Avatar

    Hi, just looking for some clarification:

    "Note that if node 0 is connected to node 1, node 1 is also connected to node 0." Based on that statement, I can see that isTree([[1],[0]]) is True, but why isTree([[1,2],[0,2],[1,2]]) is False? Node 1 and node 0 are connected, and if isTree([[1],[0]]) is True, why isn't node 0 and node 1 in [[1,2],[0,2],[1,2]] considered to be connected?

  • Voile Avatar
  • Blind4Basics Avatar

    now that it's done: needs random tests ;)

  • ZED.CWT Avatar

    Your job is to right a function

    RIGHT a function :trollface:

  • Blind4Basics Avatar

    new one... ;)

    • when testing for exceptions, you have to use test.expect_error, not test.expect (EDIT: to read, please)
    • if you do not expect errors (what you wrote in the sample tests about that seems totally weird to me, for now), explain what to do exactly and what you expect in each case
    • if exceptions has to be thrown, you have to describe that in... the description: what to do with what kind of input
    • (btw, I still don't see the description of the task, for now)
    • EDIT: don't use test.expect if you do not provide a meaningful assertion message

    Note that your sample tests talk about "exceptions" for empty nodes while you expect "False" instead

  • Blind4Basics Avatar

    actually, there's an issue: the solution setup isn't up to date either...

  • Blind4Basics Avatar

    You just forgot to tell what to do, in the description... ;)