
MATHEMATICA

a[n_] := Block[{m, qq, nv = n^3, ne}, qq = Flatten[1 + Table[n^2*z + n*x + y + s*Plus @@@ Tuples[{{0, 1}, {0, n}, {0, n^2}}], {x, 0, n2}, {y, 0, n2}, {z, 0, n2}, {s, Min[nx, ny, nz]  1}], 3]; ne = Length@ qq; m = Table[0, {ne}, {nv}]; Do[m[[i, qq[[i]]]] = 1, {i, ne}]; Total@ Quiet@ LinearProgramming[ Table[1, {nv}], m, Table[{7, 1}, {ne}], Table[{0, 1}, {nv}], Integers]]; Table[ a[n], {n, 0, 6}] (* Giovanni Resta, Feb 06 2016 *)
