Sha256: a181364701d74bed5fb1508bff54ef5ee5d39d301aa2dda12614a4bb52c9756a
Contents?: true
Size: 502 Bytes
Versions: 9
Compression:
Stored size: 502 Bytes
Contents
require 'prime3' # Need to use wall time for this test due to the sleep calls RubyProf::measure_mode = RubyProf::WALL_TIME def find_primes(arr) result = arr.select do |value| is_prime(value) end result end def find_largest(primes) largest = primes.first # Intentionally use upto for example purposes # (upto is also called from is_prime) 0.upto(primes.length-1) do |i| sleep(0.02) prime = primes[i] if prime > largest largest = prime end end largest end
Version data entries
9 entries across 9 versions & 2 rubygems