Is the sqrt here supposed always supposed to return an integer? I changed this to `L[i][j] = int(sqrt(matlist[i][j] - a))` and I think I get the result you want.