From: Harry Kakueki Date: 2012-05-19T15:30:33+09:00 Subject: Re: Ruby Arrays (Pushing Array Inside the same array) > > A = [9,18,27,36,45,54,63,72,81,90,99,108,117,126] > B = [1,1,2,1,1,3,4,5,2,1,1,3,6,1] > > I have to remove the repeated values and store the unique value from > here, > > This is the desire > > Output: A = [9,27,54,63,72,117,126] >        B = [1,2,3,4,5,6,1] > Here is one approach. I am not sure about your rules for the last elements. I also am not sure this hash will always do the trick. Maybe someone knows. a = [9,18,27,36,45,54,63,72,81,90,99,108,117,126] b = [1,1,2,1,1,3,4,5,2,1,1,3,6,1] h = Hash[*b.zip(a).reverse.flatten] d = b.uniq #> [1, 2, 3, 4, 5, 6] c = d.map{|y| h[y]} #> [9, 27, 54, 63, 72, 117] Harry