Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def weight(self):
- """The total weight of the mobile."""
- #proceed left
- def count_this(branch):
- if type(branch.contents) == type(Weight):
- return branch.contents.weight
- if type(branch.left.contents) != type(Weight):
- return count_this(branch.left)
- else type(branch.right.contents) != type(Weight):
- return count_this(branch.right)
- return count_this(self.branch.left) + count_this(self.branch.right)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement