Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@inequation
Created June 22, 2016 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inequation/93cf2222516bd62206dab14c1b3b4362 to your computer and use it in GitHub Desktop.
Save inequation/93cf2222516bd62206dab14c1b3b4362 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
points = range(700)
def dispatch(packet):
global markings, packet_count, pair_count
if 'markings' not in globals():
markings = [[i == j for j in xrange(len(points))] for i in xrange(len(points))]
for pair in packet:
if pair[1] < pair[0]:
pair = (pair[1], pair[0])
if markings[pair[0]][pair[1]]:
print('Duplicate %d, %d' % (pair[0], pair[1]))
markings[pair[0]][pair[1]] = True
if 'packet_count' not in globals():
packet_count = 0
if 'pair_count' not in globals():
pair_count = 0
packet_count += 1
pair_count += len(packet)
print('Counters: %d pairs, %d packets' % (pair_count, packet_count))
packet = []
for i in xrange(len(points)):
for j in xrange(i + 1, len(points)):
packet.append((points[i], points[j]))
if len(packet) == 100:
dispatch(packet)
packet = []
if len(packet) > 0:
dispatch(packet)
packet = []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment