from itertools import combinations

lst = []
cnt = 0
for bishop1 in range(0, 8, 2):
    for bishop2 in range(1, 8, 2):
        s = set(range(8)) - set([bishop1, bishop2])
        for queen in s:
            t = s - set([queen])
            for knight1, knight2 in combinations(t, r=2):
                u = t - set([knight1, knight2])
                rook1, king, rook2 = sorted(u)
                l = [""] * 8
                l[bishop1] = l[bishop2] = "b"
                l[queen] = "q"
                l[knight1] = l[knight2] = "n"
                l[rook1] = l[rook2] = "r"
                l[king] = "k"
                b = ' '.join(l)
                p = ' '.join(['p'] * 8)
                d = ' '.join(['.'] * 8)
                lst.append('\n'.join([b,p,d,d,d,d,p.upper(),b.upper()]))
                cnt += 1
print(cnt)
print(lst[0])
print()
print(lst[480])
                    

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: