aboutsummaryrefslogtreecommitdiff
path: root/entries/funemy/symbolic/phib.py
blob: c6fb23e4077e0cf4b11d9b108cad79a59e3f093b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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