#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1066
Task: Write a Python function that analyzes wonder_attempts table and identifies which task categories succeed most
Generated: 2026-02-12T18:54:32.445939
"""

import sqlite3
from collections import defaultdict

def analyze_wonder_attempts():
    # Example data as a list of tuples (task_category, success)
    wonder_attempts = [
        ('math', True),
        ('logic', True),
        ('math', False),
        ('physics', True),
        ('logic', False),
        ('math', True),
        ('physics', False),
        ('logic', True),
        ('math', True),
        ('physics', True),
    ]

    # Dictionary to count successes per category
    success_counts = defaultdict(int)
    total_counts = defaultdict(int)

    for category, success in wonder_attempts:
        total_counts[category] += 1
        if success:
            success_counts[category] += 1

    # Calculate success rate
    success_rate = {}
    for category in total_counts:
        success_rate[category] = success_counts[category] / total_counts[category]

    # Find the category with the highest success rate
    best_category = max(success_rate, key=success_rate.get)
    best_rate = success_rate[best_category]

    print(f"Success rates by task category:")
    for category, rate in success_rate.items():
        print(f"{category}: {rate:.2f}")

    print(f"\nThe task category with the highest success rate is '{best_category}' with a rate of {best_rate:.2f}.")

if __name__ == '__main__':
    analyze_wonder_attempts()