Problem (Gardner, 1983). Split cards into piles. A move takes one card from every pile and forms a new pile from them. If is triangular, show that from any start the piles become (and then stay there).

FactValue
fixed point for the staircase ; it is reached from every start
moves needed, triangular at most (Igusa 1985, Etienne 1991), and this is attained for
, ends in a cycle: the staircase plus extra cards on “diagonal ”, rotating; cycle length divides
methodYoung diagram, diagonals, and a potential (energy) that never increases
vector<int> bulgarianStep(vector<int> p) {           // piles in non-increasing order
    int k = sz(p);
    for (auto& x : p) x--;
    p.push_back(k);
    p.erase(remove(all(p), 0), p.end());
    sort(all(p), greater<int>());
    return p;
}
 
int stepsToFixedPoint(vector<int> p) {               // number of moves until the position repeats itself
    sort(all(p), greater<int>()); int s = 0;
    for (auto q = bulgarianStep(p); q != p; p = q, q = bulgarianStep(q)) s++;
    return s;
}