#!/bin/env python
import itertools
count=0
lst = [p for p in itertools.permutations(range(1,10),3) if sum(p) == 15 ]
print lst
for a0_0,a0_1,a0_2 in lst:
for a1_0,a1_1,a1_2 in lst:
for a2_0,a2_1,a2_2 in lst:
if a0_0 + a0_1 + a0_2 == 15 \
and a1_0 + a1_1 + a1_2 == 15 \
and a2_0 + a2_1 + a2_2 == 15 \
and a0_0 + a1_1 + a2_2 == 15 \
and a0_1 + a1_1 + a2_1 == 15 \
and a0_1 + a1_1 + a2_1 == 15 \
and a0_0 + a1_0 + a2_0 == 15 \
and a0_2 + a1_2 + a2_2 == 15 :
count = count +1
print 20*”*”
print a0_0,a0_1,a0_2
print a1_0,a1_1,a1_2
print a2_0,a2_1,a2_2
print count
~