A certain factory produces a kind of marble lock, and the height of the slot number can be represented by 5 out of 1 to 6. The restriction is that there are at least 3 different numbers in 5; the height difference between adjacent grooves cannot be 5. In the actual test, it was found that if 4 of the 5 slots corresponding to the two locks are the same in height, and the other one differs by 1, they may be mutually opened, otherwise, they cannot be mutually opened. If 60 locks are packed in a box, ask for the number of locks in a batch and the number of boxes, and ask for a plan to reduce or no longer complain about the group customers, and find the largest non-interchangeable plan for the proposed plan The number of boxes, and measure the degree to which customers complain about each other when they are randomly packed.
1. Using the idea of elimination method for the number of locks, through the Python language, the locks that do not meet the requirements are gradually eliminated. There are 5880 locks, each of which is 60, and 98 boxes can be loaded. The code is as follows:
lists = [1,2,3,4,5,6] list_alls =  for list_1 in lists: for list_2 in lists: for list_3 in lists: for list_4 in lists: for list_5 in lists: list_alls.append([list_1,list_2,list_3,list_4,list_5]) print(len(list_alls)) list_deletes_1 =  for list_all in list_alls: counts = list(set(list_all)) if len(counts) <= 2: pass else: list_deletes_1.append(list_all) print(len(list_deletes_1)) list_deletes_2 =  for list_all_1 in list_deletes_1: if abs(list_all_1-list_all_1) == 5: pass elif abs(list_all_1-list_all_1) == 5: pass elif abs(list_all_1-list_all_1) == 5: pass elif abs(list_all_1-list_all_1) == 5: pass else: list_deletes_2.append(list_all_1) print(len(list_deletes_2))
2. The packing scheme design first proves that d9→d11→…→d27→d 8→d10→d12→…→d27 has no mutual open phenomenon. Suppose a certain list is [a,b,c,d,e] (a+b+c+d+e=i is an odd number), then (a±1)bcde, a(b±1)cde, ab( c±1)de, abc(d±1)e, abcd(e±1), when it contains the unqualified items whose adjacent difference is 5 or the bit is 0, you can know a+b+c+d +e±1=i(±1) then it is an even number, which cannot be the same as any element (combination) in d9→d27, similar to d8→d10→…→d26. It can be proved that 49 boxes are the maximum number of boxes without mutual opening, that is, the odd-even boxing scheme. 3. Customers complained that the quantitative measurement uses Python to calculate all possible open pairs as 22778, and the average open coefficient α=0.001317. For one box, the number of open pairs is about 2.33, and the number of two boxes is about 9.42. The code is as follows:
import random i = 0 xiangjian_list =  hukai_counts =  list_randoms = random.sample(list_deletes_2,60) for list_randoms_1 in list_randoms: i = i+1 for list_randoms_2 in list_randoms[i:]: list_1 = [list_randoms_1-list_randoms_2,list_randoms_1-list_randoms_2,list_randoms_1-list_randoms_2,list_randoms_1-list_randoms_2,list_2 list_randoms_1 4]] xiangjian_list.append(list_1) for list_2 in xiangjian_list: if (list_2.count(0) == 4): if (list_2.count(1) == 1 | list_2.count(1) == 1): hukai_counts.append('a') print(len(hukai_counts))