Template for julia problems
This commit is contained in:
parent
7edb47e425
commit
6d9d4526df
52
src/Julia/create_template.py
Executable file
52
src/Julia/create_template.py
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
#!/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()
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user