Skip to content

Instantly share code, notes, and snippets.

@joecannatti
Created December 28, 2011 04:41
Show Gist options
  • Save joecannatti/1526326 to your computer and use it in GitHub Desktop.
Save joecannatti/1526326 to your computer and use it in GitHub Desktop.
euler35
#!/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