import os
from time import time
SOURCE_CODE_DIR = '/media/tarun/New Volume/Source codes'
TEST_DIR = '/home/tarun/Desktop/param'
SOURCE_FILE = 'aaaa.cpp'
EXE_FILE = 'aaaa.exe'
OUTPUT_FILE = '/home/tarun/Desktop/output.txt'
os .chdir ( TEST_DIR)
files = os .listdir ( )
input_files = [ file for file in files if '.in' in file ]
output_files = [ file .replace ( '.in' , '.out' ) for file in input_files]
assert len ( input_files) == len ( output_files)
os .chdir ( SOURCE_CODE_DIR)
if os .system ( 'g++ -o ' + EXE_FILE + ' --std=c++11 -D CP ' + SOURCE_FILE) :
print ( "Compilation failed" )
exit( 0 )
for i in range ( len ( input_files) ) :
infile = TEST_DIR + '/' + input_files[ i]
outfile = TEST_DIR + '/' + output_files[ i]
infile = infile.replace ( ' ' , '\\ ' )
outfile = outfile.replace ( ' ' , '\\ ' )
print ( 'Testing on' , input_files[ i] )
tic = time ( )
os .system ( './' + EXE_FILE + ' < ' + infile + ' > ' + OUTPUT_FILE)
print ( 'Time (in ms): %.3f' %( 1000 *( time ( ) -tic) ) )
os .system ( 'diff ' + outfile + ' ' + OUTPUT_FILE)
print ( '' )
aW1wb3J0IG9zCmZyb20gdGltZSBpbXBvcnQgdGltZQoKU09VUkNFX0NPREVfRElSID0gCScvbWVkaWEvdGFydW4vTmV3IFZvbHVtZS9Tb3VyY2UgY29kZXMnClRFU1RfRElSICAgICAgICA9IAknL2hvbWUvdGFydW4vRGVza3RvcC9wYXJhbScKU09VUkNFX0ZJTEUgCT0gICAnYWFhYS5jcHAnCkVYRV9GSUxFCQk9ICAJJ2FhYWEuZXhlJwpPVVRQVVRfRklMRSAgICAgPSAJJy9ob21lL3RhcnVuL0Rlc2t0b3Avb3V0cHV0LnR4dCcKCm9zLmNoZGlyKFRFU1RfRElSKQpmaWxlcyA9IG9zLmxpc3RkaXIoKQppbnB1dF9maWxlcyA9IFtmaWxlIGZvciBmaWxlIGluIGZpbGVzIGlmICcuaW4nIGluIGZpbGVdCm91dHB1dF9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