high-school-sweetheart
This commit is contained in:
42
elixir/high-school-sweetheart/lib/high_school_sweetheart.ex
Normal file
42
elixir/high-school-sweetheart/lib/high_school_sweetheart.ex
Normal file
@@ -0,0 +1,42 @@
|
||||
defmodule HighSchoolSweetheart do
|
||||
def first_letter(name) do
|
||||
name
|
||||
|> String.trim()
|
||||
|> String.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
|
||||
i1 = initials(full_name1)
|
||||
i2 = initials(full_name2)
|
||||
"""
|
||||
****** ******
|
||||
** ** ** **
|
||||
** ** ** **
|
||||
** * **
|
||||
** **
|
||||
** #{i1} + #{i2} **
|
||||
** **
|
||||
** **
|
||||
** **
|
||||
** **
|
||||
** **
|
||||
** **
|
||||
***
|
||||
*
|
||||
"""
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user