From dd101f76fa90282d5c2ed0b0a08eec2d6344611d Mon Sep 17 00:00:00 2001 From: spark Date: Mon, 26 Oct 2026 01:04:53 +0000 Subject: [PATCH] spark: add fibonacci verification artifact --- wizard-work/spark/fibonacci_verifier.py | 51 +++++++++++++++++++++++++ wizard-work/spark/verify_fibonacci.py | 20 ++++++++++ 2 files changed, 71 insertions(+) create mode 100644 wizard-work/spark/fibonacci_verifier.py create mode 100644 wizard-work/spark/verify_fibonacci.py diff --git a/wizard-work/spark/fibonacci_verifier.py b/wizard-work/spark/fibonacci_verifier.py new file mode 100644 index 0000000..4fed185 --- /dev/null +++ b/wizard-work/spark/fibonacci_verifier.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +"""Fibonacci number verification - concrete testable artifact.""" + +def fib(n: int) -> int: + """Compute the nth Fibonacci number.""" + if n <= 0: + return 0 + if n == 1: + return 1 + a, b = 0, 1 + for _ in range(2, n + 1): + a, b = b, a + b + return b + +def verify_fibs(): + """Verify known Fibonacci numbers.""" + # Known Fibonacci values + expected = { + 0: 0, + 1: 1, + 2: 1, + 3: 2, + 4: 3, + 5: 5, + 6: 8, + 7: 13, + 8: 21, + 9: 34, + 10: 55, + 15: 610, + 20: 6765, + } + + errors = [] + for n, expected_val in expected.items(): + actual = fib(n) + if actual != expected_val: + errors.append(f"fib({n}) = {actual}, expected {expected_val}") + + if errors: + for e in errors: + print(f"ERROR: {e}") + return False + + print("All Fibonacci verifications passed") + return True + +if __name__ == "__main__": + import sys + success = verify_fibs() + sys.exit(0 if success else 1) \ No newline at end of file diff --git a/wizard-work/spark/verify_fibonacci.py b/wizard-work/spark/verify_fibonacci.py new file mode 100644 index 0000000..dc68ec0 --- /dev/null +++ b/wizard-work/spark/verify_fibonacci.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +"""Verification script for fibonacci_verifier.py artifact.""" +import sys +import subprocess + +result = subprocess.run( + [sys.executable, '/root/.hermes/wizard-outputs/spark/fibonacci_verifier.py'], + capture_output=True, + text=True +) + +# Check that output contains the success message +if "All Fibonacci verifications passed" in result.stdout and result.returncode == 0: + print("VERIFICATION PASSED") + sys.exit(0) +else: + print("VERIFICATION FAILED") + print(result.stdout) + print(result.stderr) + sys.exit(1) \ No newline at end of file