"카타 7급 Count the Digit"의 두 판 사이의 차이

11번째 줄: 11번째 줄:
{{카타|7급|R|2}}
{{카타|7급|R|2}}
<source lang='r'>
<source lang='r'>
library(stringr)
nbDig <- function(n, d) {
nbDig <- function(n, d) {
  v <- 0:n
options(scipen=100)
  sum(str_count(as.character(v*v), as.character(d)))
sum(strsplit(paste((0:n)^2,collapse=""),"")[[1]]==d)
}
}
</source>
</source>
<source lang='r'>
<source lang='r'>
library(stringr)
nbDig <- function(n, d) {
nbDig <- function(n, d) {
   sum(str_count(as.character(as.integer((0:n)^2)), as.character(d)))
   sum(strsplit(paste(as.integer((0:n)^2),collapse=''),'')[[1]]==d)
}
}
</source>
</source>
<source lang='r'>
<source lang='r'>
nbDig <- function(n, d) {
nbDig <- function(n, d) {
options(scipen=100)
  nchar( gsub(paste('[^',d,']'), '', paste(as.integer((0:n)^2),collapse='')) )
sum(strsplit(paste((0:n)^2,collapse=""),"")[[1]]==d)
}
}
</source>
</source>
<source lang='r'>
<source lang='r'>
library(stringr)
nbDig <- function(n, d) {
nbDig <- function(n, d) {
   sum(strsplit(paste(as.integer((0:n)^2),collapse=''),'')[[1]]==d)
  v <- 0:n
   sum(str_count(as.character(v*v), as.character(d)))
}
}
</source>
</source>
<source lang='r'>
<source lang='r'>
library(stringr)
nbDig <- function(n, d) {
nbDig <- function(n, d) {
   nchar( gsub(paste('[^',d,']'), '', paste(as.integer((0:n)^2),collapse='')) )
   sum(str_count(as.character(as.integer((0:n)^2)), as.character(d)))
}
}
</source>
</source>

2019년 4월 25일 (목) 02:11 판

1 Kotlin

2 R

nbDig <- function(n, d) {
 options(scipen=100)
 sum(strsplit(paste((0:n)^2,collapse=""),"")[[1]]==d)
}
nbDig <- function(n, d) {
  sum(strsplit(paste(as.integer((0:n)^2),collapse=''),'')[[1]]==d)
}
nbDig <- function(n, d) {
  nchar( gsub(paste('[^',d,']'), '', paste(as.integer((0:n)^2),collapse='')) )
}
library(stringr)
nbDig <- function(n, d) {
  v <- 0:n
  sum(str_count(as.character(v*v), as.character(d)))
}
library(stringr)
nbDig <- function(n, d) {
  sum(str_count(as.character(as.integer((0:n)^2)), as.character(d)))
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}