Skip to content

Instantly share code, notes, and snippets.

@joffilyfe
Created October 25, 2018 19:43
Show Gist options
  • Save joffilyfe/f906f0631c5ecef6d0f625579d732399 to your computer and use it in GitHub Desktop.
Save joffilyfe/f906f0631c5ecef6d0f625579d732399 to your computer and use it in GitHub Desktop.
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument('--problem', required=True, help='problem\'s file')
parser.add_argument('--dir', required=True, help='problem\'s dir with input and output')
args = parser.parse_args()
def get_test_cases(dir):
files = os.listdir(dir)
files.sort()
return files
def run():
if not os.path.exists(args.dir):
print("Directory not exists")
return None
input_dir = "{}/input/".format(args.dir)
output_dir = "{}/output/".format(args.dir)
test_cases = get_test_cases(input_dir)
for case in test_cases:
input_file = "{}{}".format(input_dir, case)
output_file = "{}{}".format(output_dir, case)
os.system("python3 {} < {} | diff {} -".format(args.problem, input_file, output_file))
run()
# print(parser.print_help())
# python a_contra.py < a_contra/input/3 | diff a_contra/output/3 -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment