Created
December 28, 2011 04:41
-
-
Save joecannatti/1526326 to your computer and use it in GitHub Desktop.
euler35
This file contains hidden or 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
#!/usr/bin/env ruby | |
require 'prime' | |
require 'mathn' | |
def shifts(arr) | |
res = [] | |
tmp = arr.dup | |
(0..arr.length-1).each do |a| | |
tmp << tmp.shift | |
res << tmp.dup | |
end | |
res | |
end | |
no_zeros = Prime.each(1000000).select do |num| | |
! num.to_s.split("").include?("0") | |
end | |
res = no_zeros.select do |num| | |
shifts(num.to_s.split("")).all? do |n| | |
n.join.to_i.prime? | |
end | |
end | |
p res.size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment