-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update acronym tests to version 1.7.0 (#117)
* Update acronym tests to version 1.7.0 * Update acronym example.R to pass new tests * Disambiguate variable name
- Loading branch information
1 parent
5af1a07
commit 94a76fb
Showing
2 changed files
with
19 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
acronym <- function(input) { | ||
# split the string by spaces or hyphens | ||
split <- strsplit(input, " |-") | ||
|
||
# get the first letter of each substring | ||
first_letters <- substring(split[[1]], 1, 1) | ||
|
||
# join the acronym back together & make uppercase | ||
acronym <- paste(toupper(first_letters), collapse = "") | ||
|
||
return(acronym) | ||
words <- strsplit(input, " |-")[[1]] | ||
words <- gsub("[[:punct:]]", "", words) | ||
first_letters <- lapply(words, substring, 1, 1) | ||
toupper(paste(first_letters, collapse = "")) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters