From ac2833eb3c3e3a7c75709d992bfd9115254412de Mon Sep 17 00:00:00 2001 From: Katharine Kerr Date: Thu, 27 Oct 2022 10:54:18 -0700 Subject: Katharine's contribution with a simple fib --- entries/kekerr/fib.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 entries/kekerr/fib.ts (limited to 'entries') 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(); +} -- cgit v1.2.3-70-g09d2 From 325e5393df36cb19bc87742f86ecdad0049b5fb9 Mon Sep 17 00:00:00 2001 From: braxtonhall Date: Thu, 27 Oct 2022 13:43:38 -0700 Subject: Add Patrice --- entries/patricebelleville/fib.py | 13 +++++++++++++ people.json | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 entries/patricebelleville/fib.py (limited to 'entries') 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 d611699..a6ef1d5 100644 --- a/people.json +++ b/people.json @@ -255,6 +255,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", -- cgit v1.2.3-70-g09d2 From 13e755b6ead4c3f36f708e0213e23e84cb0cc545 Mon Sep 17 00:00:00 2001 From: Noah Weninger Date: Thu, 27 Oct 2022 16:49:27 -0400 Subject: Save 2 bytes in fib.asm --- entries/nwoeanhinnogaehr/fib.asm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'entries') 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 -- cgit v1.2.3-70-g09d2