high-school-sweetheart

This commit is contained in:
2023-12-17 21:36:59 -05:00
parent 5c704aa88f
commit 5cc59f9234
11 changed files with 436 additions and 0 deletions

View 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