Initial commit

This commit is contained in:
David Doblas Jiménez
2021-04-19 21:15:03 +02:00
commit 993517278e
17 changed files with 193 additions and 0 deletions

51
src/Python/create_template.py Executable file
View 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()