Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/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

This comment has been minimized.

Copy link
Owner Author

ficapy commented May 7, 2015


for i,n in enumerate(a):
for x,y in enumerate(a[i+1:]):
if n ==y:
print i+1,i+x+2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.