From 401c8df449eecce4df1ba459d163d20b2caf6910 Mon Sep 17 00:00:00 2001 From: Ardi Madadi Date: Sat, 10 Dec 2022 01:54:28 +1300 Subject: Ardi's entry in Python --- entries/ardier/python/main.py | 11 +++++++++++ people.json | 11 +++++++++++ 2 files changed, 22 insertions(+) create mode 100644 entries/ardier/python/main.py diff --git a/entries/ardier/python/main.py b/entries/ardier/python/main.py new file mode 100644 index 0000000..c35ad6a --- /dev/null +++ b/entries/ardier/python/main.py @@ -0,0 +1,11 @@ +def fib_helper(entry: int) -> int: + return 1 if entry in {1,2} else fib_helper(entry-1) + fib_helper(entry-2) + + +def fib(entry: int) -> int: + return 0 if entry == 0 else(-fib_helper(abs(entry)) if (entry < 0 and (entry %2 == 0)) else fib_helper(abs(entry))) + + +if __name__ == "__main__": + for i in range(-20, 20): + print(f'The fib value for {i} is {fib(i)}') \ No newline at end of file diff --git a/people.json b/people.json index 2f0ac41..f7f7ae7 100644 --- a/people.json +++ b/people.json @@ -705,5 +705,16 @@ "link": "./entries/skairunner/src/main.rs" } ] + }, + { + "github": "ardier", + "name": "Ardi Madadi", + "title": "Graduate Student", + "entries": [ + { + "name": "One-liners in Python", + "link": "./entries/ardier/python/main.py" + } + ] } ] -- cgit v1.2.3-70-g09d2