Initial commit
This commit is contained in:
51
src/Python/create_template.py
Executable file
51
src/Python/create_template.py
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/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'''#!/usr/bin/python3
|
||||
"""
|
||||
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']}
|
||||
"""
|
||||
|
||||
|
||||
def compute():
|
||||
"""
|
||||
# Statement
|
||||
"""
|
||||
|
||||
# Your code goes here
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
print("Result for problem {args['problem']}: ", compute())
|
||||
''')
|
||||
|
||||
f.write(template)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
today = datetime.datetime.now().strftime("%a %b %d %H:%M:%S %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 = "Problem" + args['problem'] + ".py"
|
||||
create_problem()
|
||||
|
||||
Reference in New Issue
Block a user