From 838c96b7523c57e9ca043ad7180786f1a62577b3 Mon Sep 17 00:00:00 2001 From: "exercism-solutions-syncer[bot]" <211797793+exercism-solutions-syncer[bot]@users.noreply.github.com> Date: Fri, 15 Aug 2025 10:35:25 +0000 Subject: [PATCH] [Sync Iteration] elixir/bob/1 --- solutions/elixir/bob/1/lib/bob.ex | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 solutions/elixir/bob/1/lib/bob.ex diff --git a/solutions/elixir/bob/1/lib/bob.ex b/solutions/elixir/bob/1/lib/bob.ex new file mode 100644 index 0000000..5aedcc8 --- /dev/null +++ b/solutions/elixir/bob/1/lib/bob.ex @@ -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