USACO template

Entries for the USACO contests require a template header and some boilerplate code. To make things easier, I put boilerplate generation into a little script.

#!/bin/sh
 
FILENAME=$1
TASKNAME=$(echo "$1" | sed -e 's/\..*$//')
TEMPLATENAME=$(echo "$1" | sed -e 's/^.*\.//')
 
sed -e 's/#TASKNAME#/'"$TASKNAME/" < template."$TEMPLATENAME" > "$FILENAME"

Template files (e.g. template.c) look like this:

/*
ID: your_id_here
LANG: C
TASK: #TASKNAME#
*/
#define PROG "#TASKNAME#"
 
#include <stdio.h>
 
int main() {
    FILE *fin  = fopen(PROG ".in", "r");
    FILE *fout = fopen(PROG ".out", "w");
 
    return 0;
}

Just give the Bash script the name of the file you need and it will make the file with the appropriate language (based off the extension given) and task name.

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.