Created
May 7, 2015 06:20
-
-
Save ficapy/b743719e740ebbaf923f to your computer and use it in GitHub Desktop.
列出2个相似的项目
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
为了不用for循环也是够拼的
for i,n in enumerate(a):
for x,y in enumerate(a[i+1:]):
if n ==y:
print i+1,i+x+2
break