Last active
March 31, 2021 17:21
-
-
Save HirbodBehnam/cd540ff1560cd83fafaf9297f8321212 to your computer and use it in GitHub Desktop.
A simple script to generate C testcases based on inputs for Quera
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# A simple script to generate C testcases based on inputs for Quera | |
# Place your input files in a folder called "raw-input" with the format of *.txt | |
# Then run the program with the code filename as the argument and then this script will generate | |
# the answers based on your program | |
# Compile the program | |
gcc -O3 -o program "$1" -lm # I include the math library as well | |
# Create the output folders if needed | |
mkdir -p "in" "out" | |
# Loop all test cases | |
counter=1 | |
for testcase in raw-input/*.txt; do | |
[ -e "$testcase" ] || continue | |
cp "$testcase" "in/input$counter.txt" | |
./program < "$testcase" > "out/output$counter.txt" | |
counter=$((counter+1)) | |
done | |
# Zip and finalize for Quera | |
zip -FSr testcases.zip "in" "out" | |
# Clean up | |
rm -rf "in" "out" "program" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment