>
> A =3D [9,18,27,36,45,54,63,72,81,90,99,108,117,126]
> B =3D [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 =3D [9,27,54,63,72,117,126]
> =A0 =A0 =A0 =A0B =3D [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 =3D [9,18,27,36,45,54,63,72,81,90,99,108,117,126]
b =3D [1,1,2,1,1,3,4,5,2,1,1,3,6,1]

h =3D Hash[*b.zip(a).reverse.flatten]
d =3D b.uniq           #> [1, 2, 3, 4, 5, 6]
c =3D d.map{|y| h[y]}  #> [9, 27, 54, 63, 72, 117]





Harry