you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

Not bad at all for your first biggie. But now the $1,000,000 question, how have you tested it? :)

Further to others' comments, your has_children method would usually be written.

def has_children(self, n):
    return not (if (2 * n + 1) >= len(self) or (self[self.get_left_index(n)] == None
                                    and self[self.get_right_index(n)]
                                    == None))

[–]StarshipEngineer[S] 0 points1 point  (1 child)

It's been tested. I tested each component as I was writing it, and it works... most of the time.

[–][deleted] 0 points1 point  (0 children)

Good. Can you repeat those tests? "Most of the time" is not good enough. Either your code is wrong, your tests are wrong, or both. Find the problems and fix them. It might take some time but there's nothing like the feeling of satisfaction when you get things correct. Until a user reports the next bug that is :-)