카타 7급 Moves in squared strings (I)

R[ | ]

reverseString <- function(s) {
  paste(rev(unlist(strsplit(s,""))),collapse="")
}
vertMirror <- function(s) {
  paste(lapply(unlist(strsplit(s,"\n")), reverseString),collapse="\n")
}
horMirror <- function(s) {
  paste(rev(unlist(strsplit(s,"\n"))),collapse="\n")
}
oper <- function(f, s) {
  f(s)
}
vertMirror <- function(s) {
    res <- lapply(strsplit(s, "\n")[[1]],
    (function (str) paste(rev(strsplit(str, "")[[1]]), collapse = "")))
    return (paste(res, collapse = '\n'))
}
horMirror <- function(s) {
    res <- rev(strsplit(s, "\n")[[1]])
    return (paste(res, collapse = "\n"))
}
oper <- function(f, s) {
   return (f(s))
}
library(stringi)
vertMirror <- function(s) {
  paste(Map(stri_reverse, unlist(strsplit(s,"\n"))), collapse="\n")
}
horMirror <- function(s) {
  paste(rev(unlist(strsplit(s,"\n"))), collapse="\n")
}
oper <- function(f, s) {
  f(s)
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}