53 lines
1.8 KiB
Python
Executable File
53 lines
1.8 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Creation of templates for the problems of Project Euler
|
|
"""
|
|
|
|
from argparse import ArgumentParser
|
|
import datetime
|
|
import inspect
|
|
|
|
|
|
def create_problem():
|
|
with open(Problem, "w+") as f:
|
|
template = inspect.cleandoc(f'''
|
|
#=
|
|
Created on {today}
|
|
|
|
@author: David Doblas Jiménez
|
|
@email: daviddoji@pm.me
|
|
|
|
Solution for Problem {args['problem']} of Project Euler
|
|
https://projecteuler.net/problem={args['problem']}
|
|
=#
|
|
|
|
function Problem{args['problem']}():
|
|
#=
|
|
Statement
|
|
=#
|
|
|
|
# Your code goes here
|
|
end
|
|
|
|
|
|
println("Time to evaluate Problem {args['problem']}:")
|
|
@time Problem{args['problem']}()
|
|
println("")
|
|
println("Result for Problem {args['problem']}: ", problem{args['problem']}())
|
|
''')
|
|
|
|
f.write(template)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
today = datetime.datetime.now().strftime("%d %b %Y")
|
|
parser = ArgumentParser(description=__doc__)
|
|
# Add your arguments here
|
|
parser.add_argument("-p", "--problem",
|
|
help="number of the problem to solve")
|
|
args = vars(parser.parse_args())
|
|
Problem = f"Problem{(args['problem']):0>3}.jl"
|
|
create_problem()
|
|
|