arr = { 11 , 2 , 4 , 4 , 5 , 6 , 10 , 8 , - 12 } function diagonalDifference(arr)dimesion = math.sqrt (# arr) arr1 = {} sum1 = 0 arr2 = {} sum2 = 0 for i= 1 ,dimesion do for j= 1 ,dimesion do if (i == j) then arr1[j] = arr[ 1 + (j - 1 ) * (
arr = {11, 2, 4, 4, 5, 6, 10, 8, -12} function diagonalDifference(arr) dimesion = math.sqrt(#arr) arr1 = {} sum1 = 0 arr2 = {} sum2 = 0 for i=1,dimesion do for j=1,dimesion do if(i == j)then arr1[j] = arr[1 + (j - 1) * (dimesion + 1)] sum1 = sum1 + arr1[j] --print(arr1[j]) end end end for i=1,dimesion do for j=1,dimesion do if((i + j) == (dimesion + 1))then arr1[j] = arr[dimesion + (j - 1) * (dimesion - 1)] sum2 = sum2 + arr1[j] --print(arr1[j]) end end end return math.abs(sum2 - sum1) end print(diagonalDifference(arr))