cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A320731 Number of possible states when placing n tokens of 2 alternating types on 3 piles.

Original entry on oeis.org

1, 3, 9, 24, 60, 141, 328, 738, 1647, 3618, 7893, 17055, 36619, 78144, 165888, 350619, 738012, 1548279, 3237611, 6752439, 14046525, 29157612, 60396996, 124885167
Offset: 0

Views

Author

Bert Dobbelaere, Oct 20 2018

Keywords

Comments

Piles start empty and have no height limit. A token can only be placed on top of a pile. The starting token is fixed.

Examples

			With alternating symbols A and B on three piles (starting with A), the following states emerge after placing 3 symbols in all 3^3 possible ways:
   1    2    3    4    5    6    7    8    9    10   11   12   13   14   15
  A                                                                 A
  B    B    B    A     A        A           A  A     A         B    B    B
  A__  AA_  A_A  AB_  AB_  ABA  A_B  AAB  A_B  BA_  BA_  BAA  AA_  _A_  _AA
   16   17   18   19   20   21   22   23   24   25   26   27
                                                           A
        A     A  A           A        A     A    B    B    B
  AAB  _AB  _AB  B_A  BAA  B_A  ABA  _BA  _BA  A_A  _AA  __A
3 pairs of states (numbered (6,22), (8,16) and (12,20)) are identical, all others are different, hence a(3)=24.
		

Crossrefs

For 2 token types on 2 piles, see A320452.

Programs

  • Python
    def fill(patterns, state_in, ply_nr, n_plies, n_players, n_stacks):
        if ply_nr>=n_plies:
            patterns.add(tuple(state_in))
        else:
            symbol=chr(ord('A')+ply_nr%n_players)
            for st in range(n_stacks):
                state_out=list(state_in)
                state_out[st]+=symbol
                fill(patterns, state_out, ply_nr+1, n_plies, n_players, n_stacks)
    def A320731(n):
        n_plies, n_players, n_stacks = n, 2, 3
        patterns=set()
        state=[""]*n_stacks
        fill(patterns, state, 0, n_plies, n_players, n_stacks)
        return len(patterns)