Is the order of lines significant? You could read lines in from both files in one list, change values to float numbers. Sort by x.y to bring near points near each other so you do not need to compare distance of every point from each other. But what if distance of p1 to p2 is 0.4, distance of p3 from p1 is 0.4 and distance of p2 to p3 is 0.7? So all neighbours of point are not neighbours of each other.
pyTony
pyMod
5,359 posts since Apr 2010
Reputation Points: 782
Solved Threads: 852
I think you could follow an algorithm similar to this one:
>>> print A
['h', 'e', 'l', 'l', 'o', ' ', 'd', 'a', 'n', 'i', 'w', 'e', 'b']
>>> print B
['t', 'h', 'i', 's', ' ', 'i', 's', ' ', 'a', 'n', ' ', 'e', 'x', 'a', 'm', 'p', 'l', 'e']
>>> for i, x in enumerate(A):
... for j, y in enumerate(B):
... if x == y:
... print i, j
...
0 1
1 11
1 17
2 16
3 16
5 4
5 7
5 10
7 8
7 13
8 9
9 2
9 5
11 11
11 17
Gribouillis
Posting Maven
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691