def execute(self, string, max_tacts=None):
        """Execute algorithm (if max_times = None, there can be forever loop)."""
        counter = 0
        self.last_rule = None

        while True:
            string = self.execute_once(string)
            if self.last_rule is None or self.last_rule[2]:
                break
            counter += 1
            if max_tacts is not None and counter >= max_tacts:
                raise TimeoutError("algorithm hasn't been stopped")

        return string