Skip to main content
added 36 characters in body
Source Link
Doorknob
  • 71.7k
  • 20
  • 143
  • 385

Ruby, 6262 61 bytes

->i{Prime.lazy.select{|x|map(&:to_s).grep(/#{i}/=~x.to_s}).first(i)[-1]}

Requires the -rprime flag (+8 bytes).

->i{            # lambda with one argument
Prime           # iterator over all primes
.lazy           # make the iterator lazy (can't evaluate infinite primes)
.select{|x|   map(&:x.to_s)  # filterconvert overthe primes which...to strings
.grep(/#{i}/=~x.to_s)   # containfind primes that regex match on the input as a(contain stringit)
}.first(i)       # take the first (input) primes that satisfy this
[-1]            # take the last of those
}

Ruby, 62 bytes

->i{Prime.lazy.select{|x|/#{i}/=~x.to_s}.first(i)[-1]}

Requires the -rprime flag (+8 bytes).

->i{            # lambda with one argument
Prime           # iterator over all primes
.lazy           # make the iterator lazy (can't evaluate infinite primes)
.select{|x|     # filter over primes which...
/#{i}/=~x.to_s  # contain the input as a string
}.first(i)      # take the first (input) primes that satisfy this
[-1]            # take the last of those
}

Ruby, 62 61 bytes

->i{Prime.lazy.map(&:to_s).grep(/#{i}/).first(i)[-1]}

Requires the -rprime flag (+8 bytes).

->i{            # lambda with one argument
Prime           # iterator over all primes
.lazy           # make the iterator lazy (can't evaluate infinite primes)
.map(&:x.to_s)  # convert the primes to strings
.grep(/#{i}/)   # find primes that regex match on the input (contain it)
.first(i)       # take the first (input) primes that satisfy this
[-1]            # take the last of those
}
Source Link
Doorknob
  • 71.7k
  • 20
  • 143
  • 385

Ruby, 62 bytes

->i{Prime.lazy.select{|x|/#{i}/=~x.to_s}.first(i)[-1]}

Requires the -rprime flag (+8 bytes).

->i{            # lambda with one argument
Prime           # iterator over all primes
.lazy           # make the iterator lazy (can't evaluate infinite primes)
.select{|x|     # filter over primes which...
/#{i}/=~x.to_s  # contain the input as a string
}.first(i)      # take the first (input) primes that satisfy this
[-1]            # take the last of those
}