From: "Jan E." Date: 2012-04-20T08:03:36+09:00 Subject: Re: finding duplicates in an array and its index number Jan E. wrote in post #1057484: > A more efficient lowlevel solution would be to iterate over the array, > compare the values and save the indices in case of duplicates. ... like this: #### x = [1, 2, 3, 2, 4, 5, 4, 4] duplicates = {} x.each_with_index do |value, i| (i + 1).upto x.length - 1 do |j| if x[j] == value duplicates[value] = [i] if duplicates[value].nil? duplicates[value] << j break end end end p duplicates #### -- Posted via http://www.ruby-forum.com/.