Created
June 22, 2016 07:14
-
-
Save inequation/93cf2222516bd62206dab14c1b3b4362 to your computer and use it in GitHub Desktop.
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/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