Skip to content

Commit

Permalink
Merge pull request #881 from codeanpeace/main
Browse files Browse the repository at this point in the history
Fix bug in win?/3
  • Loading branch information
coding-horror authored Aug 8, 2023
2 parents 11c6776 + da85e13 commit 829e918
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions 01_Acey_Ducey/elixir/acey_ducey.exs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,15 @@ defmodule Game do
end

# for a stricter win condition (non-inclusive)
defp win?({_, first}, {_, second}, {_, third}) when third > first and third < second, do: true
defp win?({_, first}, {_, second}, {_, third}) do
[floor, ceiling] = Enum.sort([first, second])
(floor < third) && (third < ceiling)
end
# for a looser win condition (inclusive)
#defp win?({_, first}, {_, second}, {_, third}) when third in first..second, do: true
defp win?(_, _, _), do: false
#defp win?({_, first}, {_, second}, {_, third}) do
#[_, middle, _] = Enum.sort([first, second, third])
#middle == third
#end

defp format({suit, value}) do
case value do
Expand Down

0 comments on commit 829e918

Please sign in to comment.