Closed bazadactyl closed 5 years ago
Moving to lovelace-problems
as solve_test_case
is defined in the problem modules.
Should note that because the solution files use dashes in the filenames (e.g. rocket-science.py
) importing the solutions is awkward and we have to use __import__
like:
_m = __import__('solutions.rocket-science', globals(), locals(), fromlist=['rocket_fuel'], level=0)
_m.rocket_fuel(45)
See: https://docs.python.org/3/library/functions.html#__import__
I think we need the dashes so that the solution filename matches the "problem name" in Django, but if not, would be nice to switch back to dashes.
X-ref: https://github.com/project-lovelace/lovelace-website/issues/38
Never mind, importlib.import_module('solutions.rocket-science')
works in the REPL but not in production. I also don't fully understand python relative imports.
Instead of using solve_test_case(test_case) the engine should load the correct solution/function from the lovelace-solutions repo. This way we don’t repeat the solution code.