diff options
author | funemy | 2022-10-25 07:14:40 +0000 |
---|---|---|
committer | funemy | 2022-10-25 07:14:40 +0000 |
commit | fdac6c60e115297a58f5b81da0c4b7f18ac758f2 (patch) | |
tree | 730660b5714bd3368f846b864d15ceb15bd75176 /entries | |
parent | dffabc78b6c1e4e01b2618f5ba274b375b5c7cc4 (diff) |
symbolic
Diffstat (limited to 'entries')
-rw-r--r-- | entries/funemy/symbolic/phib.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/entries/funemy/symbolic/phib.py b/entries/funemy/symbolic/phib.py new file mode 100644 index 0000000..30d68a8 --- /dev/null +++ b/entries/funemy/symbolic/phib.py @@ -0,0 +1,21 @@ +from typing import List + +def phib(xs: List[int]) -> bool: + """ + Instructions: + 1. `pip install crosshair-tool` + 2. modify the precondition `pre` to control the length of your fib sequence + 3. run `crosshair check phib.py` in your terminal + + pre: len(xs) >= 10 + post: __return__ != True + """ + if xs[0] != 0: + return False + if len(xs) > 1: + if xs[1] != 1: + return False + for i in range(2,len(xs)): + if xs[i] != xs[i-1] + xs[i-2]: + return False + return True |