Skip to content

Instantly share code, notes, and snippets.

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)
result = [int(line) for line in sorter.stdout]
interval = time.clock() - start
if result == sorted(sequence):
print('Result OK after %.03f secs' % interval)
print('***ERROR*** after %.03f secs' % interval)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment