转自:https://blog.csdn.net/qq_18310041/article/details/99656445
import copy # m进制 m = 5 n = 5 line = [[4,4,1,1,1],[4,3,0,1,2]] res = [] count_0 = [] count_1 = copy.deepcopy(line[1]) for i in range(n): count_0.append(m - 1 - line[0][i]) for i in range(n): if line[1][i] in count_0: res.append(m-1) count_0.remove(line[1][i]) count_1.remove(line[1][i]) count_0.sort(reverse= True) count_1.sort(reverse= False) for i in range(len(count_0)): count_0[i] = m - 1 - count_0[i] t = count_0[i] + count_1[i] if t > m-1: t =t - m res.append(t) else: res.append(t) res.sort(reverse=True) print(res)