X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=euler35.rb;fp=euler35.rb;h=a25edfe507f92c359c28d4f8ffd192ec2be6d26b;hb=8a3efb8fe4dd942185ada009d83a894dd7492042;hp=d2ba75de75e1c1c3c738cefe8c6ac937f57765a7;hpb=f4d0d9084352d850254d228d4b9605c6fd699de5;p=project-euler.git diff --git a/euler35.rb b/euler35.rb index d2ba75d..a25edfe 100644 --- a/euler35.rb +++ b/euler35.rb @@ -1,14 +1,15 @@ require 'ruby-prof' load 'primes.rb' +load 'array-numbers.rb' class Array - def to_i - self.map {|d| d.to_s}.join.to_i - end +# def to_i +# self.map {|d| d.to_s}.join.to_i +# end - def to_r - Rational(self[0].to_i, self[1].to_i) - end +# def to_r +# Rational(self[0].to_i, self[1].to_i) +# end def all_rotations (0...self.length).map {|r| self.rotate(r)} @@ -16,26 +17,27 @@ class Array end class Integer - @@primes = Primes.instance +# @@primes = Primes.instance - def prime? - @@primes.include? self - end +# def prime? +# @@primes.include? self +# end def pl @@primes.primes.length end def circular_prime? - self.to_digits.all_rotations.map {|n| n.to_i}.all? {|n| n.prime?} if self.prime? + self.prime? && self.to_digits.all_rotations.map {|n| n.to_i}.all? {|n| n.prime?} end - def to_digits - self.to_s.split('').map {|d| d.to_i} - end + # def to_digits + # self.to_s.split('').map {|d| d.to_i} + # end end + RubyProf.start # (10**6).prime?