high-school-sweetheart
This commit is contained in:
40
high-school-sweetheart/src/high_school_sweetheart.gleam
Normal file
40
high-school-sweetheart/src/high_school_sweetheart.gleam
Normal file
@@ -0,0 +1,40 @@
|
||||
import gleam/list
|
||||
import gleam/string
|
||||
|
||||
pub fn first_letter(name: String) {
|
||||
case string.first(string.trim(name)) {
|
||||
Error(_) -> ""
|
||||
Ok(first) -> first
|
||||
}
|
||||
}
|
||||
|
||||
pub fn initial(name: String) {
|
||||
first_letter(name) |> string.uppercase <> "."
|
||||
}
|
||||
|
||||
pub fn initials(full_name: String) {
|
||||
case string.split(full_name, " ") {
|
||||
[] -> ""
|
||||
[first, last] -> initial(first) <> " " <> initial(last)
|
||||
_ -> ""
|
||||
}
|
||||
}
|
||||
|
||||
pub fn pair(full_name1: String, full_name2: String) {
|
||||
"
|
||||
****** ******
|
||||
** ** ** **
|
||||
** ** ** **
|
||||
** * **
|
||||
** **
|
||||
** " <> initials(full_name1) <> " + " <> initials(full_name2) <> " **
|
||||
** **
|
||||
** **
|
||||
** **
|
||||
** **
|
||||
** **
|
||||
** **
|
||||
***
|
||||
*
|
||||
"
|
||||
}
|
||||
Reference in New Issue
Block a user