Sha256: 6c4c74975c0a7a1aaef7da685867cb7a7ebc2bc8e31829e0f9a206e6413adffb
Contents?: true
Size: 603 Bytes
Versions: 219
Compression:
Stored size: 603 Bytes
Contents
anagram <- function(subject, candidates) { # subject is a string # candidates is a character vector # break subject into vector of characters subject <- tolower(subject) test_candidates <- tolower(candidates) l <- strsplit(subject, "")[[1]] # sub out each character from l in candidates for (i in l) { test_candidates <- sub(i, "", test_candidates) } result <- candidates[test_candidates == "" & tolower(candidates) != subject & nchar(candidates) == length(l)] if (length(result) == 0) { return(c()) } return(result) }
Version data entries
219 entries across 219 versions & 1 rubygems