Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions solutions/elixir/bob/1/lib/bob.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
defmodule Bob do
@spec hey(String.t()) :: String.t()
def hey(input) do
is_question = input |> String.trim() |> String.last() == "?"
is_yelling = String.upcase(input) == input and Regex.match?(~r/\p{Lu}/u, input)
is_silent = !Regex.match?(~r/\S/u, input)

cond do
is_silent -> "Fine. Be that way!"
is_question and is_yelling -> "Calm down, I know what I'm doing!"
is_question -> "Sure."
is_yelling -> "Whoa, chill out!"
true -> "Whatever."
end
end
end