Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python script to help validate 1MB Sorter
from subprocess import *
import time
def validate(sequence):
start = time.clock()
sorter = Popen('sort1mb.exe', stdin=PIPE, stdout=PIPE, stderr=PIPE)
for value in sequence:
sorter.stdin.write('%08d\n' % value)
sorter.stdin.close()
result = [int(line) for line in sorter.stdout]
interval = time.clock() - start
if result == sorted(sequence):
print('Result OK after %.03f secs' % interval)
print(sorter.stderr.readline().strip())
else:
print('***ERROR*** after %.03f secs' % interval)
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.