You are viewing a single comment's thread. Return to all comments →
def larrysArray(a) a_sorted = a.sort (a.length-2).times do |i| index = a.find_index(i+1) if (index - i) % 2 == 0 a.insert(i, a.delete_at(index)) else a.insert(i,a.delete_at(index)) a[i+1], a[i+2] = a[i+2], a[i+1] end end return "YES" if a == a_sorted return "NO" end
Seems like cookies are disabled on this browser, please enable them to open this website
Larry's Array
You are viewing a single comment's thread. Return to all comments →
Ruby