From fdac6c60e115297a58f5b81da0c4b7f18ac758f2 Mon Sep 17 00:00:00 2001 From: funemy Date: Tue, 25 Oct 2022 00:14:40 -0700 Subject: symbolic --- entries/funemy/symbolic/phib.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 entries/funemy/symbolic/phib.py (limited to 'entries/funemy/symbolic/phib.py') 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 -- cgit v1.2.3-70-g09d2 From f6cbd54537b48f6815bf518393c5bc7ac6b2a7bd Mon Sep 17 00:00:00 2001 From: funemy Date: Tue, 25 Oct 2022 00:16:19 -0700 Subject: minor --- entries/funemy/symbolic/phib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'entries/funemy/symbolic/phib.py') diff --git a/entries/funemy/symbolic/phib.py b/entries/funemy/symbolic/phib.py index 30d68a8..c6fb23e 100644 --- a/entries/funemy/symbolic/phib.py +++ b/entries/funemy/symbolic/phib.py @@ -4,7 +4,7 @@ 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 + 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 -- cgit v1.2.3-70-g09d2