import os

def clean_unsolved_files(folder):
    for filename in os.listdir(folder):
        if filename.endswith(".txt"):
            filepath = os.path.join(folder, filename)

            with open(filepath, "r", encoding="utf-8") as f:
                content = f.read()

            # 检查是否有 "No solution found."
            if "No solution found." in content:
                print(f"删除文件: {filename}")
                os.remove(filepath)

if __name__ == "__main__":
    input_folder = "/home/liuyihong/openevolve/examples/BPP/input"  # 修改为你的目录
    clean_unsolved_files(input_folder)
