Ok went back and looked at advice given before. So far I’ve come up with this:
a = ["W","Q","R","R","W"]
a = a.shuffle
p = Array.new()
0.upto(3) do |x|
if a[0] == a[x+1]
p << a.slice!(x+1)
p << a.slice!(0)
end
end
Ok so far I got this and it seems to work for the first value in the array. I used slice because I think I should remove them from the array but still keep the values? but yeah this seems to work with comparing other values. Hmm. Also I think by slicing the values out as it goes along it avoids the issue I’ve had before where values would get re-used.