interactive-coding-challenges
interactive-coding-challenges copied to clipboard
Added __eq__ method to ensure invert_tree_challenge tests pass.
The invert_tree_challenge
Jupyter notebook has a nose unit-test that looks like this:
assert_equal(result, root)
Where result
and root
are Node
objects. I wrote a solution to this challenge that involved creating a new Node
object versus re-using the existing one, but this failed because there was no __eq__
method defined in the Node
class to enable comparison with other Nodes.
This minor pull request addresses three things:
- Changes the
__repr__
method to aid debugging. - Adds an
__eq__
method to compare nodes in a tree. - Adds a newline at the end of the file.
Thanks!
Hi @gmazzola thanks for the PR! I hope to have this reviewed within the next few days.