Files
project_euler/euler_template
Julien Lengrand-Lambert 3b6ce5578f Solves Problem 8
Prepares Problem 9

Creates a bash script which will do templates for me
2012-01-13 10:54:30 +01:00

42 lines
896 B
Bash
Executable File

#!/bin/bash
# Brrr this is ugly. You 'd better change it quickly
TYPE=$1
FILE="e_$1.py"
if [ $# -gt 1 -o $# -lt 1 ];
then
echo "Main usage is : euler_template number_of_problem"
exit 0;
fi
#generating shellbang
#echo -e "#!"$(which $TYPE)"\n" >> $FILE
echo "#!/usr/bin/env python " >>$FILE
#generating header
echo -e '"""' >> $FILE
echo -e " ##---" >> $FILE
echo -e " # "$(whoami) >> $FILE
echo -e " #Created on : "$(date)"\n #" >> $FILE
echo -e " # DESCRIPTION : Solves problem $1 of Project Euler" >> $FILE
echo -e ' ' >> $FILE
echo -e " ##---" >> $FILE
echo -e '"""' >> $FILE
# function prototype
echo -e 'def fun():' >> $FILE
echo -e ' """' >> $FILE
echo -e ' """' >> $FILE
echo -e ' ' >> $FILE
echo -e ' return 1' >> $FILE
echo -e '' >> $FILE
# main
echo -e "if __name__ == '__main__':" >> $FILE
echo -e ' print "Answer : %d" % (fun())' >> $FILE
chmod +x $FILE