ficapy
5/7/2015 - 6:20 AM

列出2个相似的项目

列出2个相似的项目

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Ficapy
# Create: '15/5/7'

#没人比我更蛋疼了吧
a = [1,2,3,2]
from itertools import permutations
llist = len(a)
x = [((n+1)/(llist-1) if not (n+1)%(llist-1) else (n+1)/(llist-1)+1,n+1) for n,i in enumerate(permutations(a,2)) if i[0]==i[1]]
if x:
    x = x[0]
    print x[0],(x[0]-1)*(llist-1)+x[1]%(llist-1)+1 if x[1]%(llist-1) else llist