diff options
author | Braxton Hall | 2022-10-24 23:57:10 +0000 |
---|---|---|
committer | GitHub | 2022-10-24 23:57:10 +0000 |
commit | 5d043fb633bffeddb5ba5a0543d121c817365a8e (patch) | |
tree | 79a740b40e895c6aa47d4ec1951cf1b093caed27 | |
parent | b9f9263c9f1590c043e38987935fc656834192b6 (diff) | |
parent | 5b3e4fb8a606385392b24dba3553db3dcb1cd711 (diff) |
Merge branch 'main' into main
-rw-r--r-- | entries/dewert99/fib.rs | 22 | ||||
-rw-r--r-- | entries/dewert99/fib_compiled | 13 | ||||
-rw-r--r-- | people.json | 13 |
3 files changed, 47 insertions, 1 deletions
diff --git a/entries/dewert99/fib.rs b/entries/dewert99/fib.rs new file mode 100644 index 0000000..ecf0a85 --- /dev/null +++ b/entries/dewert99/fib.rs @@ -0,0 +1,22 @@ +const MAX: usize = 94; + +const fn fibc<const N: usize>() -> [u64; N] { + let mut res = [0; N]; + res[1] = 1; + let mut i = 2; + while i < N { + res[i] = res[i - 1] + res[i - 2]; + i += 1; + } + res +} + +static FIB: [u64; MAX] = fibc(); + +pub fn fib(n: usize) -> Option<u64> { + if n >= MAX { + None // Fib of n wouldn't fit in 64-bits + } else { + Some(FIB[n]) + } +} diff --git a/entries/dewert99/fib_compiled b/entries/dewert99/fib_compiled new file mode 100644 index 0000000..0a0d3a8 --- /dev/null +++ b/entries/dewert99/fib_compiled @@ -0,0 +1,13 @@ +example::fib: + cmp rdi, 94 + jb .LBB0_3 + xor eax, eax + ret +.LBB0_3: + lea rax, [rip + example::FIB] + mov rdx, qword ptr [rax + 8*rdi] + mov eax, 1 + ret + +example::FIB: + .ascii "\000\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\003\000\000\000\000\000\000\000\005\000\000\000\000\000\000\000\b\000\000\000\000\000\000\000\r\000\000\000\000\000\000\000\025\000\000\000\000\000\000\000\"\000\000\000\000\000\000\0007\000\000\000\000\000\000\000Y\000\000\000\000\000\000\000\220\000\000\000\000\000\000\000\351\000\000\000\000\000\000\000y\001\000\000\000\000\000\000b\002\000\000\000\000\000\000\333\003\000\000\000\000\000\000=\006\000\000\000\000\000\000\030\n\000\000\000\000\000\000U\020\000\000\000\000\000\000m\032\000\000\000\000\000\000\302*\000\000\000\000\000\000/E\000\000\000\000\000\000\361o\000\000\000\000\000\000 \265\000\000\000\000\000\000\021%\001\000\000\000\000\0001\332\001\000\000\000\000\000B\377\002\000\000\000\000\000s\331\004\000\000\000\000\000\265\330\007\000\000\000\000\000(\262\f\000\000\000\000\000\335\212\024\000\000\000\000\000\005=!\000\000\000\000\000\342\3075\000\000\000\000\000\347\004W\000\000\000\000\000\311\314\214\000\000\000\000\000\260\321\343\000\000\000\000\000y\236p\001\000\000\000\000)pT\002\000\000\000\000\242\016\305\003\000\000\000\000\313~\031\006\000\000\000\000m\215\336\t\000\000\000\0008\f\370\017\000\000\000\000\245\231\326\031\000\000\000\000\335\245\316)\000\000\000\000\202?\245C\000\000\000\000_\345sm\000\000\000\000\341$\031\261\000\000\000\000@\n\215\036\001\000\000\000!/\246\317\001\000\000\000a93\356\002\000\000\000\202h\331\275\004\000\000\000\343\241\f\254\007\000\000\000e\n\346i\f\000\000\000H\254\362\025\024\000\000\000\255\266\330\177 \000\000\000\365b\313\2254\000\000\000\242\031\244\025U\000\000\000\227|o\253\211\000\000\0009\226\023\301\336\000\000\000\320\022\203lh\001\000\000\t\251\226-G\002\000\000\331\273\031\232\257\003\000\000\342d\260\307\366\005\000\000\273 \312a\246\t\000\000\235\205z)\235\017\000\000X\246D\213C\031\000\000\365+\277\264\340(\000\000M\322\003@$B\000\000B\376\302\364\004k\000\000\217\320\3064)\255\000\000\321\316\211).\030\001\000`\237P^W\305\001\0001n\332\207\205\335\002\000\221\r+\346\334\242\004\000\302{\005nb\200\007\000S\2110T?#\f\000\025\0056\302\241\243\023\000h\216f\026\341\306\037\000}\223\234\330\202j3\000\345!\003\357c1S\000b\265\237\307\346\233\206\000G\327\242\266J\315\331\000\251\214B~1i`\001\360c\3454|6:\002\231\360'\263\255\237\232\003\211T\r\350)\326\324\005\"E5\233\327uo\t\253\231B\203\001LD\017\315\336w\036\331\301\263\030xx\272\241\332\r\370'EW2\300\263\317\253@\275\317\354a\216\335\243h\002'\037\"B\255O\251" diff --git a/people.json b/people.json index 8a8968a..2658904 100644 --- a/people.json +++ b/people.json @@ -288,7 +288,7 @@ } ] }, - { + { "github": "davepagurek", "name": "Dave Pagurek", "title": "MSc, UBC", @@ -298,5 +298,16 @@ "link": "./entries/davepagurek/index.html" } ] + }, + { + "github": "dewert99", + "name": "David Ewert", + "title": "MSc Student, UBC", + "entries": [ + { + "name": "O(1)", + "link": "./entries/dewert99/fib.rs" + } + ] } ] |