Created
August 17, 2012 13:17
-
-
Save myokoym/3378648 to your computer and use it in GitHub Desktop.
Problem037
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! 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