Solutions for No Continuous 1's

    • @GarretVam
    • @mason, submitted in Python 2, achived 100% score
    def solve(n): 
    
        a=[0 for i in range(n)] 
        b=[0 for i in range(n)] 
        a[0] = b[0] = 1
        for i in range(1,n): 
            a[i] = a[i-1] + b[i-1] 
            b[i] = a[i-1] 
    
        return a[n-1] + b[n-1] 
    
    • @GarretVam
    • @mason, submitted in Python 3, achived 100% score
    def solve(n): 
    
        a=[0 for i in range(n)] 
        b=[0 for i in range(n)] 
        a[0] = b[0] = 1
        for i in range(1,n): 
            a[i] = a[i-1] + b[i-1] 
            b[i] = a[i-1] 
    
        return a[n-1] + b[n-1]