$\begingroup$

According to the simple-minded 7-line Python program I just wrote, there are exactly

24960 solutions.

There is at least a 25% chance that I didn't make any stupid blunders.

Here's the code:

n=0 for p in itertools.permutations([1,2,3,4,5,6,7,8,9]): a,b,c,d,e,f,g,h,i = p a,b,c,d,e,f,g,h = [a+b+c,d+e+f,g+h+i,a+d+g,b+e+h,c+f+i,a+e+i,c+e+g] if a in (b,c,d,e,f,g,h) or b in (c,d,e,f,g,h) or c in (d,e,f,g,h): continue if d in (e,f,g,h) or e==f or e==g or e==h or f==g or f==h or g==h: continue n += 1

Why two separate lines for the inequality checks? Just because it looks better that way. Why change from x in y to x==... at the end? Out of a vague idea that it might be a bit faster.

It surprised me how quickly this ran -- but 9! isn't really all that large.