"""
MathematicalProblemSolver
Generated by Eden via recursive self-improvement
2025-10-28 02:38:21.552341
"""

class MathematicalProblemSolver:
    """
    A capability to solve linear algebraic equations of the form ax + b = 0.
    
    Attributes:
        success_count (int): Number of successfully solved equations.
        error_count (int): Number of encountered errors during solving.
        past_problems (list): List of tuples containing past problems and their solutions or error messages.
    """

    def __init__(self):
        self.success_count = 0
        self.error_count = 0
        self.past_problems = []

    def solve_equation(self, a: float, b: float) -> str:
        """
        Solves the equation ax + b = 0 for x.
        
        Args:
            a (float): Coefficient of x in the equation.
            b (float): Constant term in the equation.
            
        Returns:
            str: Solution or error message indicating the result.
            
        Examples:
            solve_equation(2, 4) -> "x = -2"
            solve_equation(0, 5) -> "Error: Equation has no solution."
            solve_equation(0, 0) -> "Infinite solutions (any real x)."
        """
        try:
            if a == 0:
                if b == 0:
                    result = "Infinite solutions (any real x)."
                else:
                    result = "Error: Equation has no solution."
                self.error_count += 1
            else:
                x = -b / a
                result = f"x = {x}"
                self.success_count += 1
            
            self.past_problems.append((a, b, result))
            return result
        
        except Exception as e:
            self.error_count += 1
            return f"Error: {str(e)}"

    def review_past_problems(self) -> list:
        """
        Returns a list of past problems along with their results or error messages.
        
        Returns:
            list: List of tuples containing (a, b, result/error message).
        """
        return self.past_problems

# Example usage:
if __name__ == "__main__":
    solver = MathematicalProblemSolver()
    
    # Test case 1: Solving a simple equation
    print(solver.solve_equation(2, 4))  # Expected output: "x = -2"
    
    # Test case 2: Zero coefficient with non-zero constant
    print(solver.solve_equation(0, 5))  # Expected output: "Error: Equation has no solution."
    
    # Test case 3: Both coefficients are zero
    print(solver.solve_equation(0, 0))  # Expected output: "Infinite solutions (any real x)."
    
    # Review past problems
    print("\nReview of past problems:")
    for problem in solver.review_past_problems():
        print(problem)