Thanks to a very cool video from @standupmaths popping up on my feed I updated my #rstats #Exercism solution for the Sieve of Eratosthenes problem to essentially use
isprime <- function(n) {
!length(grep(r"(^.?$|^(..+?)\1+$)", strrep('!', n)))
}
https://youtu.be/5vbk0TwkokM
1: FALSE
2: TRUE […]
isprime <- function(n) {
!length(grep(r"(^.?$|^(..+?)\1+$)", strrep('!', n)))
}
https://youtu.be/5vbk0TwkokM
1: FALSE
2: TRUE […]
Comments