The Fibonacci sequence is defined using the following recursive formula:
F(0) = 0 F(1) = 1 F(M) = F(M - 1) + F(M - 2) if M >= 2A small frog wants to get to the other side of a river. The frog is initially located at one bank of the river (position −1) and wants to get to the other bank (position N). The frog can jump over any distance F(K), where F(K) is the K-th Fibonacci number. Luckily, there are many leaves on the river, and the frog can jump between the leaves, but only in the direction of the bank at position N.
The leaves on the river are represented in an array A consisting of N integers. Consecutive elements of array A represent consecutive positions from 0 to N − 1 on the river. Array A contains only 0s and/or 1s:
- 0 represents a position without a leaf;
- 1 represents a position containing a leaf.
The goal is to count the minimum number of jumps in which the frog can get to the other side of the river (from position −1 to position N). The frog can jump between positions −1 and N (the banks of the river) and every position containing a leaf.
For example, consider array A such that:
A[0] = 0 A[1] = 0 A[2] = 0 A[3] = 1 A[4] = 1 A[5] = 0 A[6] = 1 A[7] = 0 A[8] = 0 A[9] = 0 A[10] = 0The frog can make three jumps of length F(5) = 5, F(3) = 2 and F(5) = 5.
Write a function:
def solution(A)
that, given an array A consisting of N integers, returns the minimum number of jumps by which the frog can get to the other side of the river. If the frog cannot reach the other side of the river, the function should return −1.
For example, given:
A[0] = 0 A[1] = 0 A[2] = 0 A[3] = 1 A[4] = 1 A[5] = 0 A[6] = 1 A[7] = 0 A[8] = 0 A[9] = 0 A[10] = 0the function should return 3, as explained above.
Write an efficient algorithm for the following assumptions:
- N is an integer within the range [0..100,000];
- each element of array A is an integer that can have one of the following values: 0, 1.
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    leaves = [index for index, val in enumerate(A) if val == 1]
    if len(A) + 1 in fibonaccis: return 1
    if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    pos = -1
    posIndex = 0
    jumps = 0 
    seen = {}
    while pos < len(A):
        # print(pos, posIndex, jumps)
        # we are at last leaf, check if we can jump to end
        if posIndex == len(leaves) - 1:  
            # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
            if (len(A) - leaves[posIndex]) in fibonaccis: 
                return jumps + 1
            else: 
                # we can't jump to end, start from scratch
                jumps = 0
                posIndex = 0 
                pos = -1
                jumps = 0 
        for i in range(len(leaves) - 1, posIndex, -1):
            if leaves[i] - pos in fibonaccis and i not in seen:
                pos = leaves[i]
                posIndex = i 
                seen[posIndex] = 1
                jumps += 1
                break 
        if pos == -1: return -1
    return jumps
    # leaf_distances = [leaves[i] - leaves[i-1] for i in range(1, len(leaves))]
    # leaf_distances = [leaves[0]] + leaf_distances + [len(A) - leaves[-1]]
    # # print(fibonaccis, leaves, leaf_distances)
    # pos = -1
    # jumps = 0 
    # posIndex = -1
    # for i in range(len(leaves) - 1, 0, -1):
    #     if leaves[i] in fibonaccis:
    #         pos = leaves[i]
    #         posIndex = i
    #         jumps += 1
    #         break 
    # if pos == -1: return -1
    # while pos < len(A): 
    #     totalJump = 0 
    #     moves = 0
    #     while posIndex < len(leaf_distances):
    #         totalJump += leaf_distances[i]
    #         if totalJump not in fibonaccis: 
    #             break 
    #         else: 
    #             moves += 1
    #     # print(pos, totalJump, moves)
    #     pos += moves
    #     jumps += 1
    # return jumps
        
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    leaves = [index for index, val in enumerate(A) if val == 1]
    if len(A) + 1 in fibonaccis: return 1
    if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    pos = -1
    posIndex = 0
    jumps = 0 
    seen = {}
    while pos < len(A):
        # print(pos, posIndex, jumps)
        # we are at last leaf, check if we can jump to end
        if posIndex == len(leaves) - 1:  
            # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
            if (len(A) - leaves[posIndex]) in fibonaccis: 
                return jumps + 1
            else: 
                # we can't jump to end, start from scratch
                jumps = 0
                posIndex = 0 
                pos = -1
                jumps = 0 
        for i in range(len(leaves) - 1, posIndex, -1):
            if leaves[i] - pos in fibonaccis and i not in seen:
                pos = leaves[i]
                posIndex = i 
                seen[posIndex] = 1
                jumps += 1
                break 
        if pos == -1: return -1
    return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    leaves = []
    leaves = [index for index, val in enumerate(A) if val == 1]
    if len(A) + 1 in fibonaccis: return 1
    if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    pos = -1
    posIndex = 0
    jumps = 0 
    seen = {}
    while pos < len(A):
        # print(pos, posIndex, jumps)
        # we are at last leaf, check if we can jump to end
        if posIndex == len(leaves) - 1:  
            # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
            if (len(A) - leaves[posIndex]) in fibonaccis: 
                return jumps + 1
            else: 
                # we can't jump to end, start from scratch
                jumps = 0
                posIndex = 0 
                pos = -1
                jumps = 0 
        for i in range(len(leaves) - 1, posIndex, -1):
            if leaves[i] - pos in fibonaccis and i not in seen:
                pos = leaves[i]
                posIndex = i 
                seen[posIndex] = 1
                jumps += 1
                break 
        if pos == -1: return -1
    return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    leaves = [0] * len(A)
    
    leaves = [index for index, val in enumerate(A) if val == 1]
    if len(A) + 1 in fibonaccis: return 1
    if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    pos = -1
    posIndex = 0
    jumps = 0 
    seen = {}
    while pos < len(A):
        # print(pos, posIndex, jumps)
        # we are at last leaf, check if we can jump to end
        if posIndex == len(leaves) - 1:  
            # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
            if (len(A) - leaves[posIndex]) in fibonaccis: 
                return jumps + 1
            else: 
                # we can't jump to end, start from scratch
                jumps = 0
                posIndex = 0 
                pos = -1
                jumps = 0 
        for i in range(len(leaves) - 1, posIndex, -1):
            if leaves[i] - pos in fibonaccis and i not in seen:
                pos = leaves[i]
                posIndex = i 
                seen[posIndex] = 1
                jumps += 1
                break 
        if pos == -1: return -1
    return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    leaves = [0] * len(A)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    if len(A) + 1 in fibonaccis: return 1
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    leaves = [0] * len(A)
    for idx, val in enumerate(A): 
        if val == 1: 
            
    # leaves = [index for index, val in enumerate(A) if val == 1]
    if len(A) + 1 in fibonaccis: return 1
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    leaves = [0] * len(A)
    for idx, val in enumerate(A): 
        if val == 1: 
            if 
    # leaves = [index for index, val in enumerate(A) if val == 1]
    if len(A) + 1 in fibonaccis: return 1
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    leaves = [0] * len(A)
    unreachable = True
    for idx, val in enumerate(A): 
        if val == 1: 
            if 
    # leaves = [index for index, val in enumerate(A) if val == 1]
    if len(A) + 1 in fibonaccis: return 1
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    for idx, val in enumerate(A): 
        if val == 1: 
            if 
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[]
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[i] = 1
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
Traceback (most recent call last):
  File "exec.py", line 129, in <module>
    main()
  File "exec.py", line 91, in main
    result = solution( A )
  File "/tmp/solution.py", line 11, in solution
    leaves[i] = 1
NameError: name 'i' is not defined
                    
                    
                    
                  def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
Invalid result type, int expected, <class 'NoneType'> found.stdout:
[0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
            elif 
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append()
            elif 
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif 
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx + 1 - v in fibonaccis: 
                        
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx + 1 - v in fibonaccis: 
                        leaves[idx] = 
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx + 1 - v in fibonaccis: 
                        leaves[idx] = leaves[idx]
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx + 1 - v in fibonaccis: 
                        leaves[idx] = leaves[idx - v] + 1
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx + 1 - v in fibonaccis: 
                        leaves[idx] = leaves[idx - v] + 1
                        break
    if unreachable: return -1 
    print(leaves)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
Invalid result type, int expected, <class 'NoneType'> found.stdout:
[0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx + 1 - v in fibonaccis: 
                        leaves[idx] = leaves[idx - v] + 1
                        break
    if unreachable: return -1 
    print(leaves, re)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx + 1 - v in fibonaccis: 
                        leaves[idx] = leaves[idx - v] + 1
                        break
    if unreachable: return -1 
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
Invalid result type, int expected, <class 'NoneType'> found.stdout:
[0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0] [4]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[idx - v] + 1
                        break
    if unreachable: return -1 
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[idxv] + 1
                        break
    if unreachable: return -1 
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        break
    if unreachable: return -1 
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
Invalid result type, int expected, <class 'NoneType'> found.stdout:
[0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0] [4]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        
                        break
    if unreachable: return -1 
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
Invalid result type, int expected, <class 'NoneType'> found.stdout:
[0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0] [4, 6]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if reachables[-1]
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1]
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) + 1 reachables[-1]
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) + 1 - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
Invalid result type, int expected, <class 'NoneType'> found.stdout:
[0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0] [4, 6]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    
    if len(A) + 1 - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    print(len(A) + 1 - reachables[-1])
    if len(A) + 1 - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
Invalid result type, int expected, <class 'NoneType'> found.stdout:
6 [0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0] [4, 6]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    print(len(A) + 1 - reachables[-1], reachables[-1])
    if len(A) + 1 - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
Invalid result type, int expected, <class 'NoneType'> found.stdout:
6 6 [0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0] [4, 6]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    print(len(A) + - reachables[-1], reachables[-1])
    if len(A) + 1 - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    print(len(A) - reachables[-1], reachables[-1])
    if len(A) + 1 - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
Invalid result type, int expected, <class 'NoneType'> found.stdout:
5 6 [0, 0, 0, 0, 1, 0, 2, 0, 0, 0, 0] [4, 6]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    print(len(A) - reachables[-1], reachables[-1])
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if 
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    return 
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    return 2
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        if len(A) - idx in fibonaccis: 
                            return leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    
                    return 2
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        if len(A) - idx in fibonaccis: 
                            return leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    print(len(A), idx)
                    return 2
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        if len(A) - idx in fibonaccis: 
                            return leaves[v] + 1
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    print(len(A), idx)
                    return 2
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        if len(A) - idx in fibonaccis: 
                            return leaves[v] + 2
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    return 2
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        if len(A) - idx in fibonaccis: 
                            return leaves[v] + 2
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    return 2
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        if len(A) - idx in fibonaccis: 
                            return leaves[v] + 2
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    return 2
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        if len(A) - idx in fibonaccis: 
                            return leaves[v] + 2
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    return 2
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        if len(A) - idx in fibonaccis: 
                            return leaves[v] + 2
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
[0]
[1]
[0, 0]
[1, 1]
[0, 1, 0, 1, 0]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    return 2
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        if len(A) - idx in fibonaccis: 
                            return leaves[v] + 2
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
function result: 1
function result: 1
function result: 1
function result: 1
function result: 3
function result: -1
[0]
[1]
[0, 0]
[1, 1]
[0, 1, 0, 1, 0]
[0, 0, 0]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    return 2
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        if len(A) - idx in fibonaccis: 
                            return leaves[v] + 2
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
function result: 1
function result: 1
function result: 1
function result: 1
function result: 3
function result: -1
[0]
[1]
[0, 0]
[1, 1]
[0, 1, 0, 1, 0]
[0, 0, 0]
def solution(A):
    if len(A) == 0: return 1 
    fibonaccis = fibonacci(len(A) + 3)
    if len(A) + 1 in fibonaccis: return 1
    leaves = [0] * len(A)
    unreachable = True
    reachables = []
    for idx, val in enumerate(A): 
        if val == 1: 
            if idx + 1 in fibonaccis: 
                unreachable = False
                leaves[idx] = 1
                if len(A) - idx in fibonaccis: 
                    return 2
                reachables.append(idx)
            elif len(reachables) > 0: 
                for v in reachables: 
                    if idx - v in fibonaccis: 
                        leaves[idx] = leaves[v] + 1
                        if len(A) - idx in fibonaccis: 
                            return leaves[v] + 2
                        reachables.append(idx)
                        break
    if unreachable: return -1 
    if len(A) - reachables[-1] in fibonaccis: 
        return leaves[reachables[-1]] + 1
    print(leaves, reachables)
    # leaves = [index for index, val in enumerate(A) if val == 1]
    # if len(leaves) == 0: return -1
    # print(fibonaccis, leaves)
    # pos = -1
    # posIndex = 0
    # jumps = 0 
    # seen = {}
    # while pos < len(A):
    #     # print(pos, posIndex, jumps)
    #     # we are at last leaf, check if we can jump to end
    #     if posIndex == len(leaves) - 1:  
    #         # print("HERE", posIndex, leaves, leaves[posIndex], len(A) - leaves[posIndex])
    #         if (len(A) - leaves[posIndex]) in fibonaccis: 
    #             return jumps + 1
    #         else: 
    #             # we can't jump to end, start from scratch
    #             jumps = 0
    #             posIndex = 0 
    #             pos = -1
    #             jumps = 0 
    #     for i in range(len(leaves) - 1, posIndex, -1):
    #         if leaves[i] - pos in fibonaccis and i not in seen:
    #             pos = leaves[i]
    #             posIndex = i 
    #             seen[posIndex] = 1
    #             jumps += 1
    #             break 
    #     if pos == -1: return -1
    # return jumps
def fibonacci(N): 
    arr = [0] * N
    arr[1] = 1
    for i in range(2, N): 
        arr[i] = arr[i-1] + arr[i-2]
    return arr
The following issues have been detected: wrong answers, timeout errors.
medium random test, length = ~5,000
running time: 2.128 sec., time limit: 0.288 sec.
medium Thue-Morse sequence, lenght = 2^13
Killed. Hard limit reached: 6.000 sec.
large test with big result, length = ~100,000
Killed. Hard limit reached: 6.000 sec.
large cyclic test, length = ~100,000
Killed. Hard limit reached: 8.000 sec.
large random test, length = ~100,000
Killed. Hard limit reached: 8.000 sec.
all zeros / ones, length = ~100,000
running time: 0.932 sec., time limit: 0.592 sec.