-
Notifications
You must be signed in to change notification settings - Fork 0
/
pairwise-example.py
65 lines (58 loc) · 2.03 KB
/
pairwise-example.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
item1 = ['推荐排序','价格升序','价格降序','好评优先']
item2 = ['不限','二星及以下','两种星级','3种星级星',]
item3 = ['不限','酒店','两种类型','3中类型','4种类型','5种类型']
item4 = ['不限','silom','2个地址','3个地址']
cases = []
count=0
combinations = []
ifmove = True
x,y,z,w = '','','',''
if item1 != []:
for each in item1:
x = each
for each in item2:
y = each
if item3 == []:
case = count,x,y
cases.append(case)
count += 1
continue
else:
for each in item3:
z = each
if item4 == []:
case = count,x,y,z
cases.append(case)
count += 1
continue
else:
for each in item4:
case = count,x,y,z,w
cases.append(case)
count += 1
print(cases)
print(len(cases))
combinationnumber = 0
while combinationnumber < (count-1):
ifmove = True
for i in range(1,len(cases[1])):
j = i+1
while j<len(cases[1]):
#print(cases[combinationnumber][i]+cases[combinationnumber][j])
if (cases[combinationnumber][i]+cases[combinationnumber][j]) in combinations:
break
else:
ifmove = False
for x in range(1,len(cases[1])):
y = x+1
while y<len(cases[1]):
combinations.append(cases[combinationnumber][x]+cases[combinationnumber][y])
y += 1
j += 1
if ifmove == True:
cases.remove(cases[combinationnumber])
combinationnumber -= 1
count -= 1
combinationnumber += 1
print(cases)
print(len(cases))