Skip to main content
2 of 3
added 1938 characters in body
Nick Kennedy
  • 21.2k
  • 3
  • 17
  • 43

Jelly, 43 bytes

““”;WA;"ị@Ṫ;ɗ¥¥ⱮT>Ƈ2Ɗ$€ẎIḢAfƑʋƇ1,6Ʋ25¡2ịⱮ_3

Try it online!

A monadic link taking a list of lists of integers (representing the stacks) and returning a list of lists of integers (representing the possible sequences of moves).

Explanation

““”;                                        | Prepend two empty lists
    W                                       | Wrap in a further list
                                  Ʋ25¡      | Repeat the following 25 times:
                     $€                     | - For each current working list:
               Ɱ    Ɗ                       |   - Using each of the following as the right argument:
                T                           |     - Truthy indices (effectively here the indices of non-empty lists)
                 >Ƈ2                        |     - Keep only those greater than 2
              ¥                             |   - ... do the following as a dyad:
     A                                      |     - Absolute (used here for the side effect of copying the list)
             ¥                              |     - Following as a dyad:
      ;"    ɗ                               |       - Concatenate to following, using zipped arguments:
        ị@                                  |         - Index into list using reversed arguments
          Ṫ                                 |         - Tail, popping from list
           ;                                |         - Concatenate (to the list index)
                       Ẏ                    | - Join outer lists together
                             ʋƇ             | - Keep those lists where the following is true:
                        I                   |   - Increments (vectorises)
                         Ḣ                  |   - Head
                          A                 |   - Absolute
                           fƑ  1,6          |   - Invariant when filtered to only contain 1s and 6s
                                      2ịⱮ   | 2nd sublist of each (i.e. the sublist containing the list indices used)
                                         _3 | Minus 3
Nick Kennedy
  • 21.2k
  • 3
  • 17
  • 43