$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #110

Which fix removes the bug?

class Node:
    children = []
    def add(self, c):
        self.children.append(c)
  1. Create it per instance in __init__
  2. Create it per instance in __new__
  3. Change append to self.children + [c]
  4. Mark children as a @property value
A class attribute is shared by every instance, so all nodes get the same children list.
Play Problem Solving ▸