Diagonal Difference

  • + 1 comment

    Crazy! I got the EXACT same. Important to note you have to pass n to the function.

    def diagonalDifference(a,n)
        # Complete this function
        x = y = 0
        for i in (0...n)
            x += a[i][i]
            y += a[i][n-1-i]
        end
        puts (x-y).abs
    end