]> git.friedersdorff.com Git - max/python_unittesting.git/blobdiff - ackermann_attempt.py
Add incorrect ackermann implementation and tests
[max/python_unittesting.git] / ackermann_attempt.py
diff --git a/ackermann_attempt.py b/ackermann_attempt.py
new file mode 100644 (file)
index 0000000..3c2ba73
--- /dev/null
@@ -0,0 +1,13 @@
+def incorrect_ackermann(m, n):
+    if m == 0:
+        return m + 1
+    elif m > 0 and n == 0:
+        return incorrect_ackermann(m - 1, 1)
+    else:
+        return incorrect_ackermann(m - 1, incorrect_ackermann(m - 1, n - 1))
+
+
+
+# if m == 0            ->  n+1
+# if m > 0 and n == 0  ->  A(m-1, 1)
+# otherwise            ->  A(m-1, A(m, n - 1)