Мне нужно удалить обратное слово из массива Ruby, и у меня возникают проблемы с получением правильного вывода
Я пробовал другой способ зацикливания, я использовал exec.
# Were going to get the first line of input which is the length of the wordlist and coerce to type fixnum
pword_list_length = gets.chomp.to_i
# Initialize an empty array to hold pword_list_length
pword_list = Array.new
# loop until we have all the lines of input pushed into the array
pword_list_length.times do
pword_list.push(gets.chomp)
end
# Next were going to check to see what word we have both forward and backwards
pword_list.each do |word|
bword = word.reverse!
if pword_list.include? bword
print word.length
print bword[bword.length/2]
end
end```
```Expected Output:
3 y
Output
3y3c3e3y```