Skip to content

Instantly share code, notes, and snippets.

@Vinatorul
Last active February 18, 2017 22:30
Show Gist options
  • Save Vinatorul/0d7226e5f1804b2b2998213206e1fd67 to your computer and use it in GitHub Desktop.
Save Vinatorul/0d7226e5f1804b2b2998213206e1fd67 to your computer and use it in GitHub Desktop.
Script to help create template projects and build them during programming contests. See http://codeforces.com/submissions/Vinatorul
#!/bin/bash
dest_dir=bin
if [ ! -d $dest_dir ]; then
mkdir $dest_dir
fi
binary=$dest_dir/$3
in_file=$dest_dir/$3".in"
case $1 in
"--cxx")
src_file=$3.cxx
clean_command="rm "$binary
build_command="g++ -O2 -fno-stack-limit -x c++ -std=c++11 "$src_file" -o "$binary
run_command=$binary
template="#include <bits/stdc++.h>
using namespace std;
#define ifthen(x, y, z) (x ? y: z)
#define mp make_pair
#define mt make_tuple
const int INF = 1e9 + 1;
const double pi = acos(-1);
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.precision(20);
return 0;
}"
;;
"--kt")
binary=$binary$".jar"
src_file=$3.kt
clean_command="rm "$binary
build_command="kotlinc "$src_file" -d "$binary
run_command="kotlin -cp "$binary" "$3$"Kt"
template="fun main(args : Array<String>) {
}"
;;
*)
echo "first param --cxx or --kt expected, got "$1
exit
;;
esac
case $2 in
"-b")
if [ -e $binary ]; then
$clean_command
fi
echo "building "$src_file" into "$binary
$build_command
echo "running "$binary" on "$in_file
$run_command < $in_file
;;
"-r")
echo "running "$binary" on "$in_file
$run_command < $in_file
;;
"-c")
if [ -e $src_file ]; then
echo $3" is already exists"
exit
fi
echo "${template}" >> $src_file
if [ ! -e $in_file ]; then
$echo > $in_file
fi
echo $src_file" created succefully"
;;
*)
echo "second param -c, -b or -r expected, got "$2
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment