mirror of
https://github.com/jlengrand/project_euler.git
synced 2026-03-10 08:41:20 +00:00
42 lines
910 B
Bash
Executable File
42 lines
910 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 " # Julien Lengrand-Lambert" >> $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
|