master
 1require 'bundler/inline'
 2
 3gemfile do
 4  source 'https://rubygems.org'
 5
 6  gem 'minitest'
 7end
 8
 9require 'minitest/autorun'
10
11=begin
12Suppose you have a Stack, s, that supports only the push(x) and pop() operations.
13Show how, using only a FIFO Queue, q, you can reverse the order of all elements in s.
14=end
15
16class Example < Minitest::Test
17  def test_valid
18    s = []
19    s.push('A')
20    s.push('B')
21    s.push('C')
22
23    q = Queue.new
24    3.times { q.enq(s.pop) }
25
26    x = 3.times.map { q.deq }
27
28    assert x == ['C', 'B', 'A']
29  end
30end