Skip to content

Instantly share code, notes, and snippets.

@HirbodBehnam
Last active March 31, 2021 17:21
Show Gist options
  • Save HirbodBehnam/cd540ff1560cd83fafaf9297f8321212 to your computer and use it in GitHub Desktop.
Save HirbodBehnam/cd540ff1560cd83fafaf9297f8321212 to your computer and use it in GitHub Desktop.
A simple script to generate C testcases based on inputs for Quera
#!/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