-
Notifications
You must be signed in to change notification settings - Fork 0
/
dimond+.py
97 lines (85 loc) · 2.02 KB
/
dimond+.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
n=int(input("ENTER THE SIZE OF YOUR CHESS"))
succ2=set()
succ3=set()
succ =set()
current=[-2]*n
def make_beh(s):
global n
b1=[-2]*n
b2=[-2]*n
b3=[-2]*n
b4=[-2]*n
b5=[-2]*n
b6=[-2]*n
b7=[-2]*n
str_b1=""
str_b2=""
str_b3=""
str_b4=""
str_b5=""
str_b6=""
str_b7=""
if s in succ2:
for ib in range(0,n):
b1[n-1-int(s[ib])]=ib
b7[int(s[ib])]=ib
b2[int(s[ib])]=n-1-ib
b5[ib]=n-1-int(s[ib])
b3[n-1-ib]=n-1-int(s[ib])
b6[n-1-ib]=int(s[ib])
b4[n-1-int(s[ib])]=n-1-ib
for jb in range(0,n):
str_b1=str_b1+str(b1[jb])
str_b2=str_b2+str(b2[jb])
str_b3=str_b3+str(b3[jb])
str_b4=str_b4+str(b4[jb])
str_b5=str_b5+str(b5[jb])
str_b6=str_b6+str(b6[jb])
str_b7=str_b7+str(b7[jb])
succ2.discard(str_b1)
succ2.discard(str_b2)
succ2.discard(str_b3)
succ2.discard(str_b4)
succ2.discard(str_b5)
succ2.discard(str_b6)
succ2.discard(str_b7)
succ3.add(s)
def make_str(arr):
string1=""
for x in range(0,n):
string1=string1+str(arr[x])
return string1
def condition1(l,c):
cnt=0
for p in range(0,l):
if c!= current[p]+l-p and c!=current[p] and c!=current[p]-(l-p):
cnt=cnt+1
if cnt==l:
current[l]=c
return True
else:
return False
def tabe(l):
global n
global current
global succ
if l==n:
succ.add(make_str(current))
#current[n-1]=-2
return 0
for q in range(0,n):
if condition1(l,q):
if n!=l:
tabe(l+1)
tabe(0)
for yyy in succ:
succ2.add(yyy)
for xxx in succ:
make_beh(xxx)
print(len(succ3))
print(len(succ))
print(succ3)
print("all pattern:")
print(succ)
print("without repeated pattern:")
print(succ3-succ2)