aboutsummaryrefslogtreecommitdiff
path: root/challenge-017
diff options
context:
space:
mode:
authorDavid Ferrone <zapwai@gmail.com>2024-04-22 10:47:30 -0400
committerDavid Ferrone <zapwai@gmail.com>2024-04-22 10:47:30 -0400
commitc6d98285b8aa8be2852b9de1cbc1c9f57ded3d3b (patch)
tree563d71cab0db4fb8e4e6ea7d39434342251a4ff8 /challenge-017
parent9e76d8d75b217afd882e2a661709b63766d058be (diff)
downloadperlweeklychallenge-club-c6d98285b8aa8be2852b9de1cbc1c9f57ded3d3b.tar.gz
perlweeklychallenge-club-c6d98285b8aa8be2852b9de1cbc1c9f57ded3d3b.tar.bz2
perlweeklychallenge-club-c6d98285b8aa8be2852b9de1cbc1c9f57ded3d3b.zip
Ancient Challenges
Diffstat (limited to 'challenge-017')
-rw-r--r--challenge-017/zapwai/c/ch-1.c15
-rw-r--r--challenge-017/zapwai/javascript/ch-1.js11
-rw-r--r--challenge-017/zapwai/perl/ch-1.pl12
-rw-r--r--challenge-017/zapwai/python/ch-1.py8
-rw-r--r--challenge-017/zapwai/rust/ch-1.rs14
5 files changed, 60 insertions, 0 deletions
diff --git a/challenge-017/zapwai/c/ch-1.c b/challenge-017/zapwai/c/ch-1.c
new file mode 100644
index 0000000000..e5e063ec99
--- /dev/null
+++ b/challenge-017/zapwai/c/ch-1.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+
+int A(int m, int n) {
+ if (m == 0) {
+ return n + 1;
+ } else if (n == 0) {
+ return A(m - 1, 1);
+ } else {
+ return A(m - 1, A(m, n - 1));
+ }
+}
+
+int main() {
+ printf("%d\n", A(1,2));
+}
diff --git a/challenge-017/zapwai/javascript/ch-1.js b/challenge-017/zapwai/javascript/ch-1.js
new file mode 100644
index 0000000000..d2ad0c6bd9
--- /dev/null
+++ b/challenge-017/zapwai/javascript/ch-1.js
@@ -0,0 +1,11 @@
+function A(m, n) {
+ if (m == 0) {
+ return n + 1;
+ } else if (n == 0) {
+ return A(m - 1, 1);
+ } else {
+ return A(m - 1, A(m, n - 1));
+ }
+}
+
+console.log( A(1,2) );
diff --git a/challenge-017/zapwai/perl/ch-1.pl b/challenge-017/zapwai/perl/ch-1.pl
new file mode 100644
index 0000000000..afa8d4e808
--- /dev/null
+++ b/challenge-017/zapwai/perl/ch-1.pl
@@ -0,0 +1,12 @@
+use v5.38;
+sub A($m, $n) {
+ if ($m == 0) {
+ return $n + 1;
+ } elsif ($n == 0) {
+ return A($m - 1, 1);
+ } else {
+ return A($m - 1, A($m, $n - 1));
+ }
+}
+
+say A(1,2);
diff --git a/challenge-017/zapwai/python/ch-1.py b/challenge-017/zapwai/python/ch-1.py
new file mode 100644
index 0000000000..f3ce8c2cf6
--- /dev/null
+++ b/challenge-017/zapwai/python/ch-1.py
@@ -0,0 +1,8 @@
+def A(m, n):
+ if m == 0:
+ return n + 1
+ elif (n == 0):
+ return A(m - 1, 1)
+ else:
+ return A(m - 1, A(m, n - 1))
+print(A(1,2))
diff --git a/challenge-017/zapwai/rust/ch-1.rs b/challenge-017/zapwai/rust/ch-1.rs
new file mode 100644
index 0000000000..ec3a19eb13
--- /dev/null
+++ b/challenge-017/zapwai/rust/ch-1.rs
@@ -0,0 +1,14 @@
+
+fn A(m :i32, n :i32) -> i32 {
+ if m == 0 {
+ return n + 1;
+ } else if n == 0 {
+ return A(m - 1, 1);
+ } else {
+ return A(m - 1, A(m, n - 1));
+ }
+}
+
+fn main() {
+ println!("{}", A(1,2));
+}