| 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