#!/usr/bin/env python3

import sys
sys.path.insert(0, "c:\\Users\\Roose\\Downloads\\rev")

# Create a modified version of baby.py with debug output
with open("baby.py", "r") as f:
    orig_code = f.read()

# Find the return True line and add a print before it
modified_code = orig_code.replace(
    "return True",
    "print(f'DEBUG: g0go={g0go!r} matches expected pattern'); return True"
)

# Write to a temporary file
with open("baby_debug.py", "w") as f:
    f.write(modified_code)

print("Created baby_debug.py with debug output")

# Now try running it with various inputs
import subprocess

test_inputs = [
    "flag",
    "FLAG",
    "checker",
    "baby_checker",
    "baby",
    "rev_baby",
    "ctf_baby",
    "flag_baby",
]

for test in test_inputs:
    result = subprocess.run(
        ["python", "baby_debug.py"],
        input=test,
        capture_output=True,
        text=True,
        timeout=2
    )
    if "DEBUG:" in result.stdout or "DEBUG:" in result.stderr:
        print(f"✓ FOUND: {test}")
        print(result.stdout)
        print(result.stderr)
        break
    elif "not the flag" not in result.stdout and "not the flag" not in result.stderr:
        print(f"? MAYBE: {test}")
