def vowel_rotate(str)
  vowels = "aeiou".split("")

  vowel_indices = []
  str.each_char.with_index { |char, idx| vowel_indices << idx if vowels.include?(char) }
  vowel_indices.unshift(vowel_indices.pop)

  ret_str = ""
  vowel_idx = 0

  str.each_char do |char|
    if vowels.include?(char)
      ret_str += str[vowel_indices[vowel_idx]]
      vowel_idx += 1
    else
      ret_str += char
    end
  end

  ret_str
end

p vowel_rotate('computer')      # => "cempotur"
p vowel_rotate('oranges')       # => "erongas"
p vowel_rotate('headphones')    # => "heedphanos"
p vowel_rotate('bootcamp')      # => "baotcomp"
p vowel_rotate('awesome')       # => "ewasemo"