# File lib/quiz1/t/solutions/Carlos/solitaire.rb, line 64 def next_key # step 2: move A joker down 1 card pos = index A slice! pos pos = wrap_down(pos + 1) self[pos, 0] = A # step 3: move B joker down 2 cards pos = index B slice! pos pos = wrap_down(pos + 2) self[pos, 0] = B # step 4: triple cut first_joker, second_joker = [index(A), index(B)].sort cards_above = slice! 0...first_joker second_joker -= cards_above.length cards_below = slice! second_joker+1..-1 push *cards_above unshift *cards_below # step 5: count cut using the value of the bottom card. # reinsert above the last card cut = slice! 0, last.value self[-1,0] = cut # step 6: find the letter card = self[first.value] return Joker===card ? nil : card.value end