I have an array that stores some names. Each person solves a task and then I want to assign each solution to a different person for verification. In short this means that I need to perform a shuffle in an array in a way that no element keeps its original place. The solution I thought of is to perform a shuffle in the array until the second condition is met and here is the code for it:

```
copied = names.dup
loop do
  copied.shuffle!
  valid = true
  (0...copied.size).each do |i|
     if copied[i] == names[i]
       valid = false
       break
     end
  end
  break  if valid
end

puts copied

```

Still I feel there may be a more optimal solution to this problem. Anyone has a better idea?