From 385da8c703b20638134b1c838c3f9a8b7cf5937e Mon Sep 17 00:00:00 2001
From: braxtonhall
Date: Sun, 23 Oct 2022 15:38:10 -0700
Subject: Describe Yanze's contribution in the README
---
README.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/README.md b/README.md
index fffae69..b3dd74f 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,9 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
+### [`funemy`](https://github.com/funemy)
+- [`agda`](./entries/funemy/agda/fib1.agda)
+
### [`jyoo980`](https://github.com/jyoo980)
- [`scala`](./entries/jyoo980/scala/Fib.scala)
--
cgit v1.2.3-70-g09d2
From a7d8da6952af7f5f5e33fb8c54e9a0ffb15de47b Mon Sep 17 00:00:00 2001
From: Braxton Hall
Date: Sun, 23 Oct 2022 15:42:31 -0700
Subject: Update .gitignore
---
.gitignore | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index b25ede3..c7e318c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
node_modules
*.log
-*.pem
\ No newline at end of file
+*.pem
+.DS_Store
--
cgit v1.2.3-70-g09d2
From bbde9e43c3503e6d4ae2e180a6ac01305744ae68 Mon Sep 17 00:00:00 2001
From: Aymen Dirar
Date: Sun, 23 Oct 2022 16:01:40 -0700
Subject: rename to `.s`
---
entries/adirar111/y86/fib.s | 56 ++++++++++++++++++++++++++++++++++++++++++++
entries/adirar111/y86/fib.ys | 56 --------------------------------------------
2 files changed, 56 insertions(+), 56 deletions(-)
create mode 100644 entries/adirar111/y86/fib.s
delete mode 100644 entries/adirar111/y86/fib.ys
diff --git a/entries/adirar111/y86/fib.s b/entries/adirar111/y86/fib.s
new file mode 100644
index 0000000..156c1ae
--- /dev/null
+++ b/entries/adirar111/y86/fib.s
@@ -0,0 +1,56 @@
+# y86 implementation of
+# def fibonacci(n):
+# if n <= 1:
+# return n
+# return fibonacci(n-1) + fibonacci(n-2)
+
+.pos 0
+main:
+irmovq stack, %rsp # initialize stack pointer
+irmovq $13, %rdi # %rdi = n
+call fib # fib(n)
+halt
+
+
+fib:
+irmovq $2, %rsi
+irmovq $1, %rdx
+rrmovq %rdi, %rcx
+rrmovq %rdi, %r8
+
+subq %rsi, %rcx # %rcx = n-2
+subq %rdx, %r8 # %r8 = n-1
+jle base # goto base if n <= 1
+
+recursed:
+# save to stack
+pushq %r8 # %r8 = n-1
+
+# recurse
+rrmovq %rcx, %rdi # %rdi = n-2
+call fib # fib(n-2)
+
+# restore from stack
+popq %r8 # %r8 = n-1
+
+# save to stack
+pushq %rax # %rax = fib(n-2)
+
+# recurse
+rrmovq %r8, %rdi # %rdi = n-1
+call fib # fib(n-1)
+
+# restore from stack
+popq %r10 # r10 = fib(n-2)
+
+addq %r10, %rax # %rax = fib(n-2) + fib(n-1)
+jmp end
+
+base:
+rrmovq %rdi, %rax # return n
+
+end:
+ret
+
+.pos 0x1000
+stack:
diff --git a/entries/adirar111/y86/fib.ys b/entries/adirar111/y86/fib.ys
deleted file mode 100644
index 156c1ae..0000000
--- a/entries/adirar111/y86/fib.ys
+++ /dev/null
@@ -1,56 +0,0 @@
-# y86 implementation of
-# def fibonacci(n):
-# if n <= 1:
-# return n
-# return fibonacci(n-1) + fibonacci(n-2)
-
-.pos 0
-main:
-irmovq stack, %rsp # initialize stack pointer
-irmovq $13, %rdi # %rdi = n
-call fib # fib(n)
-halt
-
-
-fib:
-irmovq $2, %rsi
-irmovq $1, %rdx
-rrmovq %rdi, %rcx
-rrmovq %rdi, %r8
-
-subq %rsi, %rcx # %rcx = n-2
-subq %rdx, %r8 # %r8 = n-1
-jle base # goto base if n <= 1
-
-recursed:
-# save to stack
-pushq %r8 # %r8 = n-1
-
-# recurse
-rrmovq %rcx, %rdi # %rdi = n-2
-call fib # fib(n-2)
-
-# restore from stack
-popq %r8 # %r8 = n-1
-
-# save to stack
-pushq %rax # %rax = fib(n-2)
-
-# recurse
-rrmovq %r8, %rdi # %rdi = n-1
-call fib # fib(n-1)
-
-# restore from stack
-popq %r10 # r10 = fib(n-2)
-
-addq %r10, %rax # %rax = fib(n-2) + fib(n-1)
-jmp end
-
-base:
-rrmovq %rdi, %rax # return n
-
-end:
-ret
-
-.pos 0x1000
-stack:
--
cgit v1.2.3-70-g09d2
From bdd284352a0cff33cff2fdc88b154301b63b2306 Mon Sep 17 00:00:00 2001
From: Aymen Dirar
Date: Sun, 23 Oct 2022 16:04:16 -0700
Subject: links to try
---
entries/adirar111/y86/fib.s | 3 +++
1 file changed, 3 insertions(+)
diff --git a/entries/adirar111/y86/fib.s b/entries/adirar111/y86/fib.s
index 156c1ae..eae74fe 100644
--- a/entries/adirar111/y86/fib.s
+++ b/entries/adirar111/y86/fib.s
@@ -3,6 +3,9 @@
# if n <= 1:
# return n
# return fibonacci(n-1) + fibonacci(n-2)
+# run it:
+# * https://www.students.cs.ubc.ca/~cs-313/simulator/?arch=y86&impl=seq
+# * https://www.eecs.yorku.ca/~jonatan/simulator/?arch=y86&impl=seq
.pos 0
main:
--
cgit v1.2.3-70-g09d2
From 7e1694ced1cfce43f79cb4641781d91ebcc15e90 Mon Sep 17 00:00:00 2001
From: Aymen Dirar
Date: Sun, 23 Oct 2022 16:07:58 -0700
Subject: indent comment
---
entries/adirar111/y86/fib.s | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/entries/adirar111/y86/fib.s b/entries/adirar111/y86/fib.s
index eae74fe..8aa62d2 100644
--- a/entries/adirar111/y86/fib.s
+++ b/entries/adirar111/y86/fib.s
@@ -1,8 +1,10 @@
# y86 implementation of
+#
# def fibonacci(n):
-# if n <= 1:
-# return n
-# return fibonacci(n-1) + fibonacci(n-2)
+# if n <= 1:
+# return n
+# return fibonacci(n-1) + fibonacci(n-2)
+#
# run it:
# * https://www.students.cs.ubc.ca/~cs-313/simulator/?arch=y86&impl=seq
# * https://www.eecs.yorku.ca/~jonatan/simulator/?arch=y86&impl=seq
--
cgit v1.2.3-70-g09d2
From 0625380029d8eaf6a3aca4b01ac1a4bffe79c1d0 Mon Sep 17 00:00:00 2001
From: Aymen Dirar
Date: Sun, 23 Oct 2022 16:09:05 -0700
Subject: fix readme
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index b3dd74f..c56217d 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ Can you please give me a Fibonacci function? Ideally (but not necessarily) one t
For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art Gallery](https://www.instagram.com/hatch_artgallery).
### [`adirar111`](https://github.com/adirar111)
-- [`y86`](./entries/adirar111/y86/fib.ys)
+- [`y86`](./entries/adirar111/y86/fib.s)
### [`braxtonhall`](https://github.com/braxtonhall)
- [`adam`](./entries/braxtonhall/adam/main.py) (WIP)
--
cgit v1.2.3-70-g09d2
From 760fb3275b2af023d099a8c1e2a143cab41c5c6b Mon Sep 17 00:00:00 2001
From: Jonathan Chan
Date: Sun, 23 Oct 2022 16:17:39 -0700
Subject: Create Fib.agda
---
entries/ionchy/agda/Fib.agda | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 entries/ionchy/agda/Fib.agda
diff --git a/entries/ionchy/agda/Fib.agda b/entries/ionchy/agda/Fib.agda
new file mode 100644
index 0000000..a12b0a5
--- /dev/null
+++ b/entries/ionchy/agda/Fib.agda
@@ -0,0 +1,19 @@
+
+open import Agda.Builtin.Nat
+open import Agda.Builtin.List
+open import Agda.Builtin.Reflection
+
+data Fib : Nat → Nat → Set where
+ instance F0 : Fib 0 0
+ instance F1 : Fib 1 1
+ instance Fk : ∀ {k n m} → ⦃ Fib k n ⦄ → ⦃ Fib (suc k) m ⦄ → Fib (suc (suc k)) (n + m)
+
+fib' : ∀ k {n} → ⦃ Fib k n ⦄ → Nat
+fib' k {n} ⦃ fib ⦄ = n
+
+macro
+ fib : Term → Term → TC _
+ fib t hole = unify hole (def (quote fib') (arg i t ∷ []))
+ where i = arg-info visible (modality relevant quantity-ω)
+
+{- Get the [n]th Fibonacci number by normalization via C-n `fib [n]`. -}
--
cgit v1.2.3-70-g09d2
From 70773c25993c9efe2c48f53521367eb7561708e6 Mon Sep 17 00:00:00 2001
From: braxtonhall
Date: Sun, 23 Oct 2022 16:24:48 -0700
Subject: Add Yanze's Z3 version to the readme
---
README.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/README.md b/README.md
index c56217d..e2c309e 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,7 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
### [`funemy`](https://github.com/funemy)
- [`agda`](./entries/funemy/agda/fib1.agda)
+- [`z3`](./entries/funemy/z3/z3fib.sh)
### [`jyoo980`](https://github.com/jyoo980)
- [`scala`](./entries/jyoo980/scala/Fib.scala)
--
cgit v1.2.3-70-g09d2
From 8c3619fcb5e01b14eeab69bfa8c88cd75ed16ac9 Mon Sep 17 00:00:00 2001
From: braxtonhall
Date: Sun, 23 Oct 2022 16:28:11 -0700
Subject: Make Jon's work/description consistent with everyone else
---
README.md | 3 +++
entries/ionathanch/agda/Fib.agda | 19 +++++++++++++++++++
entries/ionchy/agda/Fib.agda | 19 -------------------
3 files changed, 22 insertions(+), 19 deletions(-)
create mode 100644 entries/ionathanch/agda/Fib.agda
delete mode 100644 entries/ionchy/agda/Fib.agda
diff --git a/README.md b/README.md
index e2c309e..d126e3b 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,9 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
+### [`ionathanch`](https://github.com/ionathanch)
+- [`agda`](./entries/ionathanch/agda/Fib.agda)
+
### [`funemy`](https://github.com/funemy)
- [`agda`](./entries/funemy/agda/fib1.agda)
- [`z3`](./entries/funemy/z3/z3fib.sh)
diff --git a/entries/ionathanch/agda/Fib.agda b/entries/ionathanch/agda/Fib.agda
new file mode 100644
index 0000000..a12b0a5
--- /dev/null
+++ b/entries/ionathanch/agda/Fib.agda
@@ -0,0 +1,19 @@
+
+open import Agda.Builtin.Nat
+open import Agda.Builtin.List
+open import Agda.Builtin.Reflection
+
+data Fib : Nat → Nat → Set where
+ instance F0 : Fib 0 0
+ instance F1 : Fib 1 1
+ instance Fk : ∀ {k n m} → ⦃ Fib k n ⦄ → ⦃ Fib (suc k) m ⦄ → Fib (suc (suc k)) (n + m)
+
+fib' : ∀ k {n} → ⦃ Fib k n ⦄ → Nat
+fib' k {n} ⦃ fib ⦄ = n
+
+macro
+ fib : Term → Term → TC _
+ fib t hole = unify hole (def (quote fib') (arg i t ∷ []))
+ where i = arg-info visible (modality relevant quantity-ω)
+
+{- Get the [n]th Fibonacci number by normalization via C-n `fib [n]`. -}
diff --git a/entries/ionchy/agda/Fib.agda b/entries/ionchy/agda/Fib.agda
deleted file mode 100644
index a12b0a5..0000000
--- a/entries/ionchy/agda/Fib.agda
+++ /dev/null
@@ -1,19 +0,0 @@
-
-open import Agda.Builtin.Nat
-open import Agda.Builtin.List
-open import Agda.Builtin.Reflection
-
-data Fib : Nat → Nat → Set where
- instance F0 : Fib 0 0
- instance F1 : Fib 1 1
- instance Fk : ∀ {k n m} → ⦃ Fib k n ⦄ → ⦃ Fib (suc k) m ⦄ → Fib (suc (suc k)) (n + m)
-
-fib' : ∀ k {n} → ⦃ Fib k n ⦄ → Nat
-fib' k {n} ⦃ fib ⦄ = n
-
-macro
- fib : Term → Term → TC _
- fib t hole = unify hole (def (quote fib') (arg i t ∷ []))
- where i = arg-info visible (modality relevant quantity-ω)
-
-{- Get the [n]th Fibonacci number by normalization via C-n `fib [n]`. -}
--
cgit v1.2.3-70-g09d2
From 2927387ace15b664d80e2335084e50d478581733 Mon Sep 17 00:00:00 2001
From: braxtonhall
Date: Sun, 23 Oct 2022 16:42:08 -0700
Subject: Add Margo's fibs
---
README.md | 3 +++
entries/margoseltzer/efficiency.c | 23 +++++++++++++++++++++++
2 files changed, 26 insertions(+)
create mode 100644 entries/margoseltzer/efficiency.c
diff --git a/README.md b/README.md
index d126e3b..d43be80 100644
--- a/README.md
+++ b/README.md
@@ -25,6 +25,9 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
### [`jyoo980`](https://github.com/jyoo980)
- [`scala`](./entries/jyoo980/scala/Fib.scala)
+## [`margoseltzer`](https://github.com/margoseltzer)
+- [`efficiency`](./entries/margoseltzer/efficiency.c)
+
### [`Metroxe`](https://github.com/Metroxe)
- [`html`](./entries/Metroxe/index.html)
diff --git a/entries/margoseltzer/efficiency.c b/entries/margoseltzer/efficiency.c
new file mode 100644
index 0000000..6e017f3
--- /dev/null
+++ b/entries/margoseltzer/efficiency.c
@@ -0,0 +1,23 @@
+unsigned long foo(unsigned long n) {
+ if (n < 2) return (n);
+ return(foo(n - 1) + foo(n - 2));
+}
+
+// Efficiency of expression
+
+unsigned long bar(unsigned long n) {
+ unsigned long i, last;
+ unsigned long sum, tmp;
+
+ if (n < 2) return (n);
+ last = 0;
+ sum = 1;
+ for (i = 2; i <= n; i++) {
+ tmp = sum;
+ sum += last;
+ last = tmp;
+ }
+ return (sum);
+}
+
+// Efficiency in resource utilization
--
cgit v1.2.3-70-g09d2
From 668e1a0266a0c59a0e420571dbbcb445e72361ae Mon Sep 17 00:00:00 2001
From: Braxton Hall
Date: Sun, 23 Oct 2022 16:42:37 -0700
Subject: Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index d43be80..d8e5f75 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,7 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
### [`jyoo980`](https://github.com/jyoo980)
- [`scala`](./entries/jyoo980/scala/Fib.scala)
-## [`margoseltzer`](https://github.com/margoseltzer)
+### [`margoseltzer`](https://github.com/margoseltzer)
- [`efficiency`](./entries/margoseltzer/efficiency.c)
### [`Metroxe`](https://github.com/Metroxe)
--
cgit v1.2.3-70-g09d2
From 97d0bca7470bef068b5852a94c5e51c103b0400c Mon Sep 17 00:00:00 2001
From: Tarcisio-Teixeira
Date: Sun, 23 Oct 2022 16:48:02 -0700
Subject: Create fib.py
---
entries/Tarcisio-Teixeira/fib.py | 5 +++++
1 file changed, 5 insertions(+)
create mode 100644 entries/Tarcisio-Teixeira/fib.py
diff --git a/entries/Tarcisio-Teixeira/fib.py b/entries/Tarcisio-Teixeira/fib.py
new file mode 100644
index 0000000..1246517
--- /dev/null
+++ b/entries/Tarcisio-Teixeira/fib.py
@@ -0,0 +1,5 @@
+def fib(n,arr={},v =-1):
+ if v>=0:
+ arr[n]=v
+ return v
+ return arr[n] if n in arr.keys() else fib(n, arr, (3*n*n*n - 9*n*n+13*n)//6 if n <= 3 else fib(n//2-1,arr)*fib(n-n//2,arr) + fib(n//2,arr)*fib(n-n//2+1,arr))
--
cgit v1.2.3-70-g09d2
From c4b8d5fcd71f4f8a006234dabc5a1958e32cd63e Mon Sep 17 00:00:00 2001
From: braxtonhall
Date: Sun, 23 Oct 2022 16:56:25 -0700
Subject: Give Tarcisio a temporary name
---
README.md | 3 +++
1 file changed, 3 insertions(+)
diff --git a/README.md b/README.md
index d8e5f75..67db343 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,9 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
### [`Metroxe`](https://github.com/Metroxe)
- [`html`](./entries/Metroxe/index.html)
+## [`Tarcisio-Teixeira`](https://github.com/Tarcisio-Teixeira)
+- [`logn?`](./entries/Tarcisio-Teixeira/fib.py)
+
## Contributing
To contribute just make a PR into the `main` branch!
--
cgit v1.2.3-70-g09d2
From d0513187789505955e41441973c63848ec247cbc Mon Sep 17 00:00:00 2001
From: Tarcisio-Teixeira
Date: Sun, 23 Oct 2022 17:02:58 -0700
Subject: Update fib.py
---
entries/Tarcisio-Teixeira/fib.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/entries/Tarcisio-Teixeira/fib.py b/entries/Tarcisio-Teixeira/fib.py
index 1246517..a73cdd2 100644
--- a/entries/Tarcisio-Teixeira/fib.py
+++ b/entries/Tarcisio-Teixeira/fib.py
@@ -2,4 +2,4 @@ def fib(n,arr={},v =-1):
if v>=0:
arr[n]=v
return v
- return arr[n] if n in arr.keys() else fib(n, arr, (3*n*n*n - 9*n*n+13*n)//6 if n <= 3 else fib(n//2-1,arr)*fib(n-n//2,arr) + fib(n//2,arr)*fib(n-n//2+1,arr))
+ return arr[n] if n in arr.keys() else fib(n, arr, (2*n*n*n - 9*n*n+13*n)//6 if n <= 3 else fib(n//2-1,arr)*fib(n-n//2,arr) + fib(n//2,arr)*fib(n-n//2+1,arr))
--
cgit v1.2.3-70-g09d2
From 4be354380ae27d55b50ca795397e52fced857e53 Mon Sep 17 00:00:00 2001
From: braxtonhall
Date: Sun, 23 Oct 2022 17:10:24 -0700
Subject: oops
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 67db343..efc713a 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,7 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
### [`Metroxe`](https://github.com/Metroxe)
- [`html`](./entries/Metroxe/index.html)
-## [`Tarcisio-Teixeira`](https://github.com/Tarcisio-Teixeira)
+### [`Tarcisio-Teixeira`](https://github.com/Tarcisio-Teixeira)
- [`logn?`](./entries/Tarcisio-Teixeira/fib.py)
## Contributing
--
cgit v1.2.3-70-g09d2
From e5de46c67d3edeb6e4bc96889a6594ab77f07265 Mon Sep 17 00:00:00 2001
From: Shayan Hosseini
Date: Sun, 23 Oct 2022 17:25:21 -0700
Subject: added shayanh's entry
---
README.md | 3 +++
entries/shayanh/matrix.go | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+)
create mode 100644 entries/shayanh/matrix.go
diff --git a/README.md b/README.md
index efc713a..be6323b 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,9 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
### [`Tarcisio-Teixeira`](https://github.com/Tarcisio-Teixeira)
- [`logn?`](./entries/Tarcisio-Teixeira/fib.py)
+### [`shayanh`](https://github.com/shayanh)
+- [`matrix`](./entries/shayanh/matrix.go)
+
## Contributing
To contribute just make a PR into the `main` branch!
diff --git a/entries/shayanh/matrix.go b/entries/shayanh/matrix.go
new file mode 100644
index 0000000..3f374cb
--- /dev/null
+++ b/entries/shayanh/matrix.go
@@ -0,0 +1,40 @@
+package main
+
+type fibmat [2][2]int
+
+func matmul(m1 fibmat, m2 fibmat) (m3 fibmat) {
+ for i := 0; i < 2; i++ {
+ for j := 0; j < 2; j++ {
+ for k := 0; k < 2; k++ {
+ m3[i][j] += m1[i][k] * m2[k][j]
+ }
+ }
+ }
+ return
+}
+
+func matpow(m fibmat, n int) fibmat {
+ if n == 0 {
+ return [2][2]int{
+ {1, 0},
+ {0, 1},
+ }
+ } else if n%2 == 0 {
+ t := matpow(m, n/2)
+ return matmul(t, t)
+ } else {
+ t := matpow(m, n-1)
+ return matmul(t, m)
+ }
+}
+
+func fib(n int) int {
+ m := matpow(
+ [2][2]int{
+ {1, 1},
+ {1, 0},
+ },
+ n,
+ )
+ return m[0][1]
+}
--
cgit v1.2.3-70-g09d2
From 48902c10c743feac836d2c51a3bf1824e8db378a Mon Sep 17 00:00:00 2001
From: braxtonhall
Date: Sun, 23 Oct 2022 17:30:17 -0700
Subject: Add fib-lang
---
.gitmodules | 3 +++
README.md | 3 +++
entries/wilbowma/fib-lang | 1 +
3 files changed, 7 insertions(+)
create mode 100644 .gitmodules
create mode 160000 entries/wilbowma/fib-lang
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..1088a73
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "entries/wilbowma/fib-lang"]
+ path = entries/wilbowma/fib-lang
+ url = git@github.com:wilbowma/fib-lang.git
diff --git a/README.md b/README.md
index efc713a..986aac9 100644
--- a/README.md
+++ b/README.md
@@ -34,6 +34,9 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
### [`Tarcisio-Teixeira`](https://github.com/Tarcisio-Teixeira)
- [`logn?`](./entries/Tarcisio-Teixeira/fib.py)
+### [`wilbowma`](https://github.com/wilbowma)
+- [`fib-lang`](./entries/wilbowma/fib-lang)
+
## Contributing
To contribute just make a PR into the `main` branch!
diff --git a/entries/wilbowma/fib-lang b/entries/wilbowma/fib-lang
new file mode 160000
index 0000000..2ec2d1d
--- /dev/null
+++ b/entries/wilbowma/fib-lang
@@ -0,0 +1 @@
+Subproject commit 2ec2d1dfd141220882d824cf3dac5b374ed291f3
--
cgit v1.2.3-70-g09d2
From 2dbd7c53ce88c10e1b47d0c7a878ccb68513a00b Mon Sep 17 00:00:00 2001
From: braxtonhall
Date: Sun, 23 Oct 2022 17:31:24 -0700
Subject: Fix fib-lang link
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 986aac9..a3926aa 100644
--- a/README.md
+++ b/README.md
@@ -35,7 +35,7 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
- [`logn?`](./entries/Tarcisio-Teixeira/fib.py)
### [`wilbowma`](https://github.com/wilbowma)
-- [`fib-lang`](./entries/wilbowma/fib-lang)
+- [`fib-lang`](https://github.com/wilbowma/fib-lang/tree/2ec2d1dfd141220882d824cf3dac5b374ed291f3)
## Contributing
To contribute just make a PR into the `main` branch!
--
cgit v1.2.3-70-g09d2
From f4e141bb52b93096642a81a35b28c59dcc8dcdb5 Mon Sep 17 00:00:00 2001
From: braxtonhall
Date: Sun, 23 Oct 2022 17:39:49 -0700
Subject: Add an editorconfig so I can actually read the code on GitHub
---
.editorconfig | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 .editorconfig
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..c57f5e7
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,11 @@
+root = true
+
+[*]
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
+indent_style = tab
+indent_size = 4
+
+[*.md]
+trim_trailing_whitespace = false
--
cgit v1.2.3-70-g09d2
From 46a659c983911b87b38b20cd4b28ab9176e4fdb3 Mon Sep 17 00:00:00 2001
From: braxtonhall
Date: Sun, 23 Oct 2022 19:13:46 -0700
Subject: Add fib-java
---
README.md | 3 +++
entries/nritschel/fib-java/fib.iml | 13 +++++++++++++
.../fib-java/src/CachedFibonacciNumberFactory.java | 13 +++++++++++++
.../nritschel/fib-java/src/FibonacciCalculator.java | 3 +++
.../fib-java/src/FibonacciCalculatorImpl.java | 17 +++++++++++++++++
entries/nritschel/fib-java/src/FibonacciNumber.java | 19 +++++++++++++++++++
.../fib-java/src/FibonacciNumberFactory.java | 3 +++
entries/nritschel/fib-java/src/Main.java | 21 +++++++++++++++++++++
.../fib-java/src/NaiveFibonacciNumberFactory.java | 6 ++++++
9 files changed, 98 insertions(+)
create mode 100644 entries/nritschel/fib-java/fib.iml
create mode 100644 entries/nritschel/fib-java/src/CachedFibonacciNumberFactory.java
create mode 100644 entries/nritschel/fib-java/src/FibonacciCalculator.java
create mode 100644 entries/nritschel/fib-java/src/FibonacciCalculatorImpl.java
create mode 100644 entries/nritschel/fib-java/src/FibonacciNumber.java
create mode 100644 entries/nritschel/fib-java/src/FibonacciNumberFactory.java
create mode 100644 entries/nritschel/fib-java/src/Main.java
create mode 100644 entries/nritschel/fib-java/src/NaiveFibonacciNumberFactory.java
diff --git a/README.md b/README.md
index 3944068..4eb6fa1 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,9 @@ For a submission to the upcoming "Reclaim your space" exhibition at [Hatch Art G
### [`Metroxe`](https://github.com/Metroxe)
- [`html`](./entries/Metroxe/index.html)
+### [`nritschel`](https://github.com/nritschel)
+- [`fib-java`](./entries/nritschel/fib-java/src)
+
### [`shayanh`](https://github.com/shayanh)
- [`matrix`](./entries/shayanh/matrix.go)
diff --git a/entries/nritschel/fib-java/fib.iml b/entries/nritschel/fib-java/fib.iml
new file mode 100644
index 0000000..815e958
--- /dev/null
+++ b/entries/nritschel/fib-java/fib.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entries/nritschel/fib-java/src/CachedFibonacciNumberFactory.java b/entries/nritschel/fib-java/src/CachedFibonacciNumberFactory.java
new file mode 100644
index 0000000..5c404e8
--- /dev/null
+++ b/entries/nritschel/fib-java/src/CachedFibonacciNumberFactory.java
@@ -0,0 +1,13 @@
+import java.util.HashMap;
+
+public class CachedFibonacciNumberFactory implements FibonacciNumberFactory {
+ private final HashMap cachedNumbers = new HashMap<>();
+
+ @Override
+ public FibonacciNumber getFibonacciNumber(int num) {
+ if (!cachedNumbers.containsKey(num)) {
+ cachedNumbers.put(num, new FibonacciNumber(num));
+ }
+ return cachedNumbers.get(num);
+ }
+}
diff --git a/entries/nritschel/fib-java/src/FibonacciCalculator.java b/entries/nritschel/fib-java/src/FibonacciCalculator.java
new file mode 100644
index 0000000..8806c20
--- /dev/null
+++ b/entries/nritschel/fib-java/src/FibonacciCalculator.java
@@ -0,0 +1,3 @@
+public interface FibonacciCalculator {
+ public int calculateFibonacci(FibonacciNumber fib);
+}
diff --git a/entries/nritschel/fib-java/src/FibonacciCalculatorImpl.java b/entries/nritschel/fib-java/src/FibonacciCalculatorImpl.java
new file mode 100644
index 0000000..7bb5ee9
--- /dev/null
+++ b/entries/nritschel/fib-java/src/FibonacciCalculatorImpl.java
@@ -0,0 +1,17 @@
+public class FibonacciCalculatorImpl implements FibonacciCalculator {
+ private final FibonacciNumberFactory factory;
+
+ public FibonacciCalculatorImpl(FibonacciNumberFactory factory) {
+ this.factory = factory;
+ }
+
+ @Override
+ public int calculateFibonacci(FibonacciNumber fib) {
+ if (fib.getNumber() <= 2) {
+ return 1;
+ }
+ else {
+ return factory.getFibonacciNumber(fib.getNumber() - 1).calculate(this) + factory.getFibonacciNumber(fib.getNumber() - 2).calculate(this);
+ }
+ }
+}
diff --git a/entries/nritschel/fib-java/src/FibonacciNumber.java b/entries/nritschel/fib-java/src/FibonacciNumber.java
new file mode 100644
index 0000000..fc9381f
--- /dev/null
+++ b/entries/nritschel/fib-java/src/FibonacciNumber.java
@@ -0,0 +1,19 @@
+public class FibonacciNumber {
+ private final int number;
+ private Integer result;
+
+ public FibonacciNumber(int number) {
+ this.number = number;
+ }
+
+ public int getNumber() {
+ return number;
+ }
+
+ public int calculate(FibonacciCalculator calculator) {
+ if (result == null) {
+ result = calculator.calculateFibonacci(this);
+ }
+ return result;
+ }
+}
diff --git a/entries/nritschel/fib-java/src/FibonacciNumberFactory.java b/entries/nritschel/fib-java/src/FibonacciNumberFactory.java
new file mode 100644
index 0000000..42ef6c2
--- /dev/null
+++ b/entries/nritschel/fib-java/src/FibonacciNumberFactory.java
@@ -0,0 +1,3 @@
+public interface FibonacciNumberFactory {
+ public FibonacciNumber getFibonacciNumber(int num);
+}
diff --git a/entries/nritschel/fib-java/src/Main.java b/entries/nritschel/fib-java/src/Main.java
new file mode 100644
index 0000000..8ae46f1
--- /dev/null
+++ b/entries/nritschel/fib-java/src/Main.java
@@ -0,0 +1,21 @@
+public class Main {
+ public static void main(String[] args) {
+ if (args.length < 1) {
+ System.out.println("""
+ Please provide:
+ 1. fibonacci number to compute, and
+ 2. (optional) the calculation method (naive or cached).""");
+ }
+ else {
+ FibonacciNumberFactory factory;
+ if (args.length >= 2 && args[1].equals("naive")) {
+ factory = new NaiveFibonacciNumberFactory();
+ }
+ else {
+ factory = new CachedFibonacciNumberFactory();
+ }
+ FibonacciCalculator calculator = new FibonacciCalculatorImpl(factory);
+ System.out.println(factory.getFibonacciNumber(Integer.parseInt(args[0])).calculate(calculator));
+ }
+ }
+}
diff --git a/entries/nritschel/fib-java/src/NaiveFibonacciNumberFactory.java b/entries/nritschel/fib-java/src/NaiveFibonacciNumberFactory.java
new file mode 100644
index 0000000..5185a8b
--- /dev/null
+++ b/entries/nritschel/fib-java/src/NaiveFibonacciNumberFactory.java
@@ -0,0 +1,6 @@
+public class NaiveFibonacciNumberFactory implements FibonacciNumberFactory {
+ @Override
+ public FibonacciNumber getFibonacciNumber(int num) {
+ return new FibonacciNumber(num);
+ }
+}
--
cgit v1.2.3-70-g09d2