5 kyu
Mistaking a forest for a tree
58Arcitech
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
python new test framework is required. updated in this fork
python: function name should be snake_case
This is not always true. In fact, from the sample tests:
The wording is either misleading (if such a case needs to be checked) or otherwise plain wrong.
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?No problems, I'm on it.
Also, please add [[1,2],[0,2],[0,1],[4],[3]] i.e. ring of 3 plus two more connected to each other
all done.
Would there be way to remove solutions that had passed the tests previously but no longer do? I would certainly like to retract mine.
Nope. But you can submit a new one.
This comment has been hidden.
This comment has been hidden.
what are E and V?
This comment has been hidden.
This comment has been hidden.
Gotcha, thanks. Well then this folds into Blind4Basic's point below about needing tests with unconnected graphs.
Hi,
Don't resolve to fast: about random tests, that's not enough. ;)
Fixed! (Only took 2 months)
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 whyisTree([[1,2],[0,2],[1,2]]) is False
? Node 1 and node 0 are connected, and ifisTree([[1],[0]]) is True
, why isn't node 0 and node 1 in[[1,2],[0,2],[1,2]]
considered to be connected?My bad,
[[1,2],[0,2],[1,2]]
should actually be[[1,2],[0,2],[0,1]]
That[[1,2],[0,2],[1,2]]
is indeed connected, and if you ignore the node connected to itself, is also a tree. Also, you need to test not just for connectedness, but also if the graph is a tree or not.[[1,2],[0,2],[0,1]]
is not a tree, because it contains the path0->1->2->0
I hope that clarifies things.
How different is this from https://www.codewars.com/kata/is-it-a-tree?
The data type is much different, it is python, and also the graphs can be unconnected so you also need to check if the graph is connected.
now that it's done: needs random tests ;)
Added. Once in a blue moon, there might be a tree that it says should be false, but that will happen extremly rarely, and can be fixed by simply trying again.
RIGHT a function :trollface:
you're right... ;p
new one... ;)
test.expect_error
, nottest.expect
(EDIT: to read, please)test.expect
if you do not provide a meaningful assertion messageNote that your sample tests talk about "exceptions" for empty nodes while you expect "False" instead
I think that's fixed.
actually, there's an issue: the solution setup isn't up to date either...
Sorry about that, I think I fixed it. This is my first kata, so I'm not really used to al of this.
You just forgot to tell what to do, in the description... ;)