I have the following script in ruby:
set = []
for i in 2..100
for j in 2..100
set << i**j
end
end
puts set.uniq!.count
When running this script with Ruby version ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
, the output is 8243.
When I run this script with Ruby version ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-darwin12.4.0]
, the output is 9183 (which is what I expect the result to be).
Any ideas why there is a discrepancy between the two versions?
I get same results for both version (1.8, 1.9.3)
BTW, chaining
uniq!
withcount
is not a good idea, becauseuniq!
returns nil if there's no duplicate.