diff --git a/solutions/elixir/high-school-sweetheart/2/lib/high_school_sweetheart.ex b/solutions/elixir/high-school-sweetheart/2/lib/high_school_sweetheart.ex new file mode 100644 index 0000000..c439bcc --- /dev/null +++ b/solutions/elixir/high-school-sweetheart/2/lib/high_school_sweetheart.ex @@ -0,0 +1,30 @@ +defmodule HighSchoolSweetheart do + def first_letter(name) do + name + |> String.trim + |> String.codepoints + |> List.first + end + + def initial(name) do + name + |> first_letter + |> String.upcase + |> Kernel.<>(".") + end + + def initials(full_name) do + full_name + |> String.split + |> Enum.map(&initial/1) + |> Enum.join(" ") + end + + def pair(full_name1, full_name2) do + """ + ❤-------------------❤ + | #{initials(full_name1)} + #{initials(full_name2)} | + ❤-------------------❤ + """ + end +end