aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--entries/kekerr/fib.ts16
-rw-r--r--entries/nwoeanhinnogaehr/fib.asm12
-rw-r--r--entries/patricebelleville/fib.py13
-rw-r--r--people.json21
4 files changed, 56 insertions, 6 deletions
diff --git a/entries/kekerr/fib.ts b/entries/kekerr/fib.ts
new file mode 100644
index 0000000..cc42fcf
--- /dev/null
+++ b/entries/kekerr/fib.ts
@@ -0,0 +1,16 @@
+function fibonacci(n: number): string {
+ if (n <= 0) {
+ return "Surely that's a mistake! We can't give you anything interesting!";
+ }
+
+ if (n == 1) {
+ return "This one's easy: [1]";
+ }
+
+ const seq = [1, 1];
+ for(let i = 2; i < n; i++) {
+ seq.push(seq[i-1] + seq[i-2]);
+ }
+
+ return "Fibonacci this: " + seq.toString();
+}
diff --git a/entries/nwoeanhinnogaehr/fib.asm b/entries/nwoeanhinnogaehr/fib.asm
index 26ccf11..729958f 100644
--- a/entries/nwoeanhinnogaehr/fib.asm
+++ b/entries/nwoeanhinnogaehr/fib.asm
@@ -25,25 +25,25 @@ entry:
loop:
mov eax,esi
push 10
- pop ebp
- push ebp
- jmp format
+ mov ecx,esp
+ jmp skip
dw $20 ; e_phentsize
dw 1 ; e_phnum
+skip:
+ pop ebp
format:
cdq
div ebp
inc ebx
- dec esp
+ dec ecx
or edx,'0'
- mov [esp],dl
+ mov [ecx],dl
test eax,eax
jnz format
print:
mov al,4
- mov ecx,esp
mov edx,ebx
mov bl,1
int 0x80
diff --git a/entries/patricebelleville/fib.py b/entries/patricebelleville/fib.py
new file mode 100644
index 0000000..767ce11
--- /dev/null
+++ b/entries/patricebelleville/fib.py
@@ -0,0 +1,13 @@
+def fibonacci(n):
+ return fib_helper(n, 0, 1)
+
+def fib_helper(n, prev, curr):
+ # Base cases
+ if n < 0:
+ raise ValueError('Negative argument to fibonnaci')
+ if n == 0:
+ return prev
+ if n == 1:
+ return curr
+ return fib_helper(n-1, curr, prev + curr)
+
diff --git a/people.json b/people.json
index 3523e01..5b9eb1e 100644
--- a/people.json
+++ b/people.json
@@ -256,6 +256,16 @@
]
},
{
+ "name": "Patrice Belleville",
+ "title": "Associate Professor of Teaching, Computer Science, UBC",
+ "entries": [
+ {
+ "name": "fib",
+ "link": "./entries/patricebelleville/fib.py"
+ }
+ ]
+ },
+ {
"github": "perryliao",
"name": "Perry Liao",
"title": "BSc, UBC",
@@ -488,6 +498,17 @@
{
"name": "rb-cr fibonacci",
"link": "./entries/komodoooo/"
+ }
+ ]
+ },
+ {
+ "github": "kekerr",
+ "name": "Katharine Kerr",
+ "title": "'Whether you think you can or can't, either way you are right.' - Henry Ford",
+ "entries": [
+ {
+ "name": "TypeScript",
+ "link": "./entries/kekerr/fib.ts"
}
]
}