Skip to content

Commit a4bb99b

Browse files
committed
Fix calculation of time in ways_to_win function
1 parent b4e0f00 commit a4bb99b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

06/sol.exs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ defmodule Day06 do
1414

1515
defp ways_to_win(time, distance) do
1616
disc = :math.sqrt(time * time - 4 * distance)
17-
t1 = time + disc / 2
18-
t2 = time - disc / 2
17+
t1 = (time + disc) / 2.0
18+
t2 = (time - disc) / 2.0
1919
ceil(t1) - floor(t2) - 1
2020
end
2121

0 commit comments

Comments
 (0)