-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconflict.py
73 lines (69 loc) · 2.12 KB
/
conflict.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
import numpy as numpy
rootNode = [[13, 14, 15, 0],
[9, 10, 11, 12],
[5, 6, 7, 8],
[1, 2, 3, 4]]
def confilict (data):
arr = numpy.copy(data)
currentNumber = 0
count = 0
add = 4
numConfilict = 0
check = 0
# horizontal
for i in range(12) :
currentNumber += 1
if(currentNumber % 4 == 0):
currentNumber += 1
add += 4
count = currentNumber
# مکان گره ی در حال بررسی
for i in range(4):
for j in range(4):
if arr[i][j] == currentNumber:
num1_i = i
num1_j = j
break
while count < add :
# مکان با شماره های بعدی
count += 1
for i in range(4):
for j in range(4):
if arr[i][j] == count:
num2_i = i
num2_j = j
check = 1
break
if num1_i is num2_i and check:
if num1_j > num2_j :
numConfilict += 1
check = 0
# vertical
currentNumber = 0
check = 0
for i in range(12) :
currentNumber += 1
count = currentNumber
# مکان گره ی در حال بررسی
for i in range(4):
for j in range(4):
if arr[i][j] == currentNumber:
num1_i = i
num1_j = j
break
while count < 13 :
# مکان با شماره های بعدی
count += 4
for i in range(4):
for j in range(4):
if arr[i][j] == count:
num2_i = i
num2_j = j
check = 1
break
if num1_j is num2_j and check:
if num1_i > num2_i :
numConfilict += 1
check = 0
numConfilict *= 2
return numConfilict