Skip to content

Instantly share code, notes, and snippets.

@lune-sta
Created August 24, 2012 18:51
Show Gist options
  • Select an option

  • Save lune-sta/3454246 to your computer and use it in GitHub Desktop.

Select an option

Save lune-sta/3454246 to your computer and use it in GitHub Desktop.
Project Euler 35
require 'prime'
p Prime.each(10**6).select{|a|(1..a.to_s.size-1).map{|b|a.to_s.scan(/.{#{b}}|.+\Z/)}.map{|b|b.push(b.shift).join.to_i}.select{|b|b.prime?.!}.empty?}.size # 55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment