Skip to content

Commit 6ee7f29

Browse files
committed
Add rust to solve parameter
1 parent 50d94db commit 6ee7f29

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/advent_of_code.ex

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@ defmodule AdventOfCode do
1616
Solves for `year` and `day`.
1717
"""
1818
@spec solve(year(), day()) :: {any(), any()}
19-
def solve(year, day) do
20-
{:ok, Module.concat([AdventOfCode, get_year_module(year), get_day_module(day)]).run()}
19+
def solve(year, day, rust? \\ false) do
20+
solution = :timer.tc(fn ->
21+
case rust? do
22+
true ->
23+
{_, result} = AdventOfCode.RustNif.solve(year, day)
24+
result
25+
false -> Module.concat([AdventOfCode, get_year_module(year), get_day_module(day)]).run()
26+
end
27+
end)
28+
{:ok, solution}
2129
rescue
2230
_ in FunctionClauseError -> {:error, :invalid_args}
2331
_ in UndefinedFunctionError -> {:error, :not_yet_solved}

0 commit comments

Comments
 (0)