First code.
Use enumerable methods.
Use Enumerable#index.