#!/usr/bin/env python3
"""Auto-generated by AGI Loop cycle #1301
Task: _


</think>

Write a Python function that identifies novel patterns in a list of broadcast messages by comparing them to a reference set, returning the count of unique patterns found in the latest me
Generated: 2026-02-13T17:54:43.585513
"""

import difflib

def find_unique_patterns(reference_messages, latest_messages):
    reference_set = set(reference_messages)
    unique_patterns = []

    for msg in latest_messages:
        if msg not in reference_set:
            unique_patterns.append(msg)
        else:
            # Compare with similar messages in reference
            for ref_msg in reference_set:
                ratio = difflib.SequenceMatcher(None, msg, ref_msg).ratio()
                if ratio < 0.8:  # Threshold for novel pattern
                    unique_patterns.append(msg)
                    break

    return len(unique_patterns)

if __name__ == '__main__':
    reference_messages = [
        "Weather update: Sunny with a chance of rain.",
        "Traffic report: Major delays on Highway 10.",
        "Flight status: Delayed by 2 hours."
    ]

    latest_messages = [
        "Weather forecast: Cloudy with possible showers.",
        "Traffic update: Congestion on Highway 10.",
        "Flight info: Delayed by 1 hour."
    ]

    count = find_unique_patterns(reference_messages, latest_messages)
    print(f"Count of unique patterns: {count}")