diff --git a/wizard-work/spark/fibonacci_artifact.py b/wizard-work/spark/fibonacci_artifact.py new file mode 100644 index 0000000..e1f8175 --- /dev/null +++ b/wizard-work/spark/fibonacci_artifact.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +"""Fib verifier - generates and validates Fibonacci sequence""" + +def fib(n): + """Return nth Fibonacci number (0-indexed)""" + a, b = 0, 1 + for _ in range(n): + a, b = b, a + b + return a + +def main(): + results = [] + for i in range(15): + n = fib(i) + results.append({"n": i, "fib": n}) + + # Verify against known values + known = {0: 0, 1: 1, 2: 1, 3: 2, 4: 3, 5: 5, 6: 8, 7: 13, 8: 21, 9: 34, 10: 55} + all_correct = all(r["fib"] == known.get(r["n"], fib(r["n"])) for r in results[:11]) + + output = f"""Fibonacci Verification Report +{'=' * 40} +Sequence (first 15 terms): +{', '.join(str(r['fib']) for r in results)} +Last computed: F(14) = {results[-1]['fib']} +Validation: {'PASSED' if all_correct else 'FAILED'} +Exit code would be: {0 if all_correct else 1} +""" + + with open('/root/.hermes/wizard-outputs/spark/fibonacci_output.txt', 'w') as f: + f.write(output) + + print(output) + return 0 if all_correct else 1 + +if __name__ == "__main__": + exit(main()) \ No newline at end of file diff --git a/wizard-work/spark/fibonacci_output.txt b/wizard-work/spark/fibonacci_output.txt index 72952ae..e314c02 100644 --- a/wizard-work/spark/fibonacci_output.txt +++ b/wizard-work/spark/fibonacci_output.txt @@ -1,21 +1,7 @@ -First 20 Fibonacci numbers: -1: 0 -2: 1 -3: 1 -4: 2 -5: 3 -6: 5 -7: 8 -8: 13 -9: 21 -10: 34 -11: 55 -12: 89 -13: 144 -14: 233 -15: 377 -16: 610 -17: 987 -18: 1597 -19: 2584 -20: 4181 +Fibonacci Verification Report +======================================== +Sequence (first 15 terms): +0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377 +Last computed: F(14) = 377 +Validation: PASSED +Exit code would be: 0