# File lib/quiz1/t/solutions/Dennis Ranke/solitaire.rb, line 16 def next_letter ## # move the jokers ## 2.times do |j| # find the joker index = @deck.index(52 + j) # remove it from the deck @deck.delete_at(index) # calculate new index index = ((index + j) % 53) + 1 # insert the joker at that index @deck[index, 0] = 52 + j end ## # do the tripple cut ## # first find both jokers a = @deck.index(52) b = @deck.index(53) # sort the two indeces low, hi = [a, b].sort # get the lower and upper parts of the deck upper = @deck.slice!((hi + 1)..-1) lower = @deck.slice!(0, low) # swap them @deck = upper + @deck + lower ## # do the count cut ## # find out the number of cards to cut count = value_at(53) # remove them from the top of the deck cards = @deck.slice!(0, count) # reinsert them just above the lowest card @deck[-1, 0] = cards return letter_at(value_at(0)) end