simple-exercises/ruby-exercises/easy-1.rb
# Write a method that takes in a string and an array of indices in the
# string. Produce a new string, which contains letters from the input
# string in the order specified by the indices of the array of indices.
Write a method that takes in a string and an array of indices in the
string. Produce a new string, which contains letters from the input
string in the order specified by the indices of the array of indices.
Write a method that takes in a string and an array of indices in the string . Produce a new string which contains letters from the input string in the order specified by the indices of the array of indices .
def scramble_string(string, positions)
  letters = ""
  positions.each do |i|
    letters += string[i]
  end
  letters
end
def scramble_string ( string , positions ) letters = "" positions . each do | i | letters += string [ i ] end letters end
Write a method that takes in a string and an array of indices in the
string.
Write a method that takes in a string and an array of indices in the string .
string
<not_specific>
positions
<not_specific>