Skip to content

Instantly share code, notes, and snippets.

@myokoym
Created August 17, 2012 13:17
Show Gist options
  • Save myokoym/3378648 to your computer and use it in GitHub Desktop.
Save myokoym/3378648 to your computer and use it in GitHub Desktop.
Problem037
#! ruby
require 'prime'
ans = []
Prime.each do |n|
next if n < 10
flag = true
l = n.to_s.split(//)
until l.empty?
flag = false unless Prime.prime?(l.join.to_i)
l.shift
end
r = n.to_s.split(//)
until r.empty?
flag = false unless Prime.prime?(r.join.to_i)
r.pop
end
ans << n if flag
break if ans.size == 11
end
p ans.inject(:+)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment