Skip to content

Commit

Permalink
Update 206
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbantuelle committed Aug 27, 2018
1 parent 98c06bd commit de3aaf1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions 206.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
ceiling = 1_389_026_620
floor = 1_010_101_010

(ceiling..floor).step(10) do |i|
if i % 10 == 0
num = (i**2).to_s
if num[16] == '9' && num[14] == '8' && num[12] == '7' && num[10] == '6' && num[8] == '5' && num[6] == '4' && num[4] == '3' && num[2] == '2'
puts "Original Number: #{i} - Square: #{num}"
break
end
require 'pp'

start_time = Time.now
(floor..ceiling).step(10) do |i|
num = (i**2).to_s
if num[16] == '9' && num[14] == '8' && num[12] == '7' && num[10] == '6' && num[8] == '5' && num[6] == '4' && num[4] == '3' && num[2] == '2'
pp "Original Number: #{i} - Square: #{num}"
break
end
end
pp "Found in #{Time.now - start_time} seconds"

0 comments on commit de3aaf1

Please sign in to comment.