Ruff in pre-commit
This commit is contained in:
52
src/project_euler_python/create_template.py
Executable file
52
src/project_euler_python/create_template.py
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Creation of templates for the problems of Project Euler
|
||||
"""
|
||||
|
||||
import datetime
|
||||
import inspect
|
||||
from argparse import ArgumentParser
|
||||
|
||||
|
||||
def create_problem():
|
||||
with open(Problem, "w+") as f:
|
||||
template = inspect.cleandoc(
|
||||
f'''#!/usr/bin/env python
|
||||
"""
|
||||
Created on {today}
|
||||
|
||||
@author: David Doblas Jiménez
|
||||
@email: daviddoji@pm.me
|
||||
|
||||
Solution for problem {(args["problem"]):0>3} from Project Euler
|
||||
https://projecteuler.net/problem={args["problem"]}
|
||||
"""
|
||||
|
||||
from utils import timeit
|
||||
|
||||
|
||||
@timeit("Problem {(args["problem"]):0>3}")
|
||||
def compute():
|
||||
"""
|
||||
# Statement
|
||||
"""
|
||||
|
||||
# Your code goes here
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(f"Result for Problem {(args["problem"]):0>3} is {{compute()}}")
|
||||
''' # noqa: E501
|
||||
)
|
||||
|
||||
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}.py"
|
||||
create_problem()
|
||||
Reference in New Issue
Block a user