title: Print all permutations of possible outcomes given N rounds of RPS using a stack
body: <p>Given n rounds, print all possible permutations to rock paper scissor using a stack as the main strategy.</p>
  
  <p>I use to know how to do this, but I'm stump after not having exercise stacks for a while.</p>
  
  <p>Can someone provide a helpful hint as to how the stack should be populated?</p>
  
  <p>I know there are 3^n outputs for n input.</p>
  
  <p>For n = 1, the expected answer is 3. A possible solution would be:</p>
  
  <pre><code>def rps(n)
    stack = []
    answer = []
  
    if n &gt; 0
      stack.push([r,p,s])
      n -= 1
  
    while !stack.isEmpty()
      array = stack.pop();
  
      forEach elem in array
        // I still can't figure out where to go from here!!
  </code></pre>
  
  <p>I know in the recursive solution, it'll go r,p,s for n=1</p>
  
  <p>for n=2, the answer gets appended with rr, rp, rs, pr, pp, ps, sr, sp, ss</p>
  
  <p>for n=3, it'll be rrr, rrp, rrs, rpr, etc...</p>