카타 7급 Rotate for a Max

1 Kotlin[ | ]

2 R[ | ]

maxRot <- function(n) {
  max = n = as.character(n)
  l = nchar(n)
  for( i in 1:l-1 ) {
    n = paste( substr(n,0,i-1), substr(n,i+1,l), substr(n,i,i), sep="" )
    if( n > max ) max = n
  }
  as.numeric(max)
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}