initial
This commit is contained in:
83
scripts/verify_solutions.py
Normal file
83
scripts/verify_solutions.py
Normal file
@ -0,0 +1,83 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Verify that solutions were extracted successfully
|
||||
Shows sample solutions from the database
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import pymysql
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
def load_env_config():
|
||||
"""Load database configuration from .env file"""
|
||||
load_dotenv()
|
||||
|
||||
config = {
|
||||
'host': os.getenv('DB_HOST'),
|
||||
'user': os.getenv('DB_USER'),
|
||||
'password': os.getenv('DB_PASSWORD'),
|
||||
'database': os.getenv('DB_NAME'),
|
||||
'port': int(os.getenv('DB_PORT', 3306)),
|
||||
'charset': 'utf8mb4'
|
||||
}
|
||||
|
||||
return config
|
||||
|
||||
|
||||
def main():
|
||||
print("Solution Verification Tool")
|
||||
print("=" * 60)
|
||||
|
||||
# Load configuration and connect
|
||||
config = load_env_config()
|
||||
connection = pymysql.connect(**config)
|
||||
cursor = connection.cursor()
|
||||
|
||||
# Get statistics
|
||||
cursor.execute("SELECT COUNT(*) FROM arc_jsons")
|
||||
total_records = cursor.fetchone()[0]
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM arc_jsons WHERE solution IS NOT NULL")
|
||||
with_solutions = cursor.fetchone()[0]
|
||||
|
||||
cursor.execute("SELECT COUNT(*) FROM arc_jsons WHERE solution IS NULL")
|
||||
without_solutions = cursor.fetchone()[0]
|
||||
|
||||
print(f"\nDatabase Statistics:")
|
||||
print(f" Total records: {total_records}")
|
||||
print(f" With solutions: {with_solutions}")
|
||||
print(f" Without solutions: {without_solutions}")
|
||||
|
||||
# Show 5 sample solutions
|
||||
print(f"\nSample Solutions:")
|
||||
print("-" * 60)
|
||||
|
||||
cursor.execute("SELECT id, solution FROM arc_jsons WHERE solution IS NOT NULL LIMIT 5")
|
||||
samples = cursor.fetchall()
|
||||
|
||||
for i, (puzzle_id, solution_json) in enumerate(samples, 1):
|
||||
solution = json.loads(solution_json)
|
||||
rows = len(solution)
|
||||
cols = len(solution[0]) if rows > 0 else 0
|
||||
|
||||
print(f"\n{i}. Puzzle ID: {puzzle_id}")
|
||||
print(f" Grid size: {cols}×{rows}")
|
||||
print(f" Grid data:")
|
||||
|
||||
# Show grid visually
|
||||
for row in solution[:5]: # Show up to 5 rows
|
||||
print(f" {row}")
|
||||
|
||||
if rows > 5:
|
||||
print(f" ... ({rows - 5} more rows)")
|
||||
|
||||
connection.close()
|
||||
print(f"\n{'=' * 60}")
|
||||
print("Verification complete!")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user