Ask Your Question

Revision history [back]

I think the following code gives the good answer (but is far from optimal), parameters are assumed to be partitions:

def get_paths(top, bot):
    if top == bot:
        return [[top]]
    path_list = []
    for p in top.down_list():
        if p.contains(bot):
            path_list += get_paths(p, bot)
    for u in path_list:
        u.append(top)
    return path_list

For example:

sage: gp = get_paths (Partition([3,3,1]),Partition([2,1])); len(gp)
8
sage: len (get_paths (Partition([3,3,2]),Partition([1])))
42

Actually we are computing functions already defined in Sage:

sage: sst = StandardSkewTableaux([[3, 3, 1], [2, 1]])
sage: sst.cardinality()
8
sage: StandardTableaux([3,3,2]).cardinality()
42

Use sst.list() to get the "same" list as the one computed by get_paths(). And look at the source code of these functions ! Amitiés.

I think the following code gives the good answer output (but is far from optimal), parameters are assumed to be partitions:

def get_paths(top, bot):
    if top == bot:
        return [[top]]
    path_list = []
    for p in top.down_list():
        if p.contains(bot):
            path_list += get_paths(p, bot)
    for u in path_list:
        u.append(top)
    return path_list

For example:

sage: gp = get_paths (Partition([3,3,1]),Partition([2,1])); len(gp)
8
sage: len (get_paths (Partition([3,3,2]),Partition([1])))
42

Actually we are computing functions already defined in Sage:

sage: sst = StandardSkewTableaux([[3, 3, 1], [2, 1]])
sage: sst.cardinality()
8
sage: StandardTableaux([3,3,2]).cardinality()
42

Use sst.list() to get the "same" list as the one computed by get_paths(). And look at the source code of these functions ! Amitiés.

I think the following code gives the good output (but is far from optimal), optimal, many computations are repeated again and again, as in the naive recursive computation of the Fibonacci sequence), here parameters are assumed to be partitions:

def get_paths(top, bot):
    if top == bot:
        return [[top]]
    path_list = []
    for p in top.down_list():
        if p.contains(bot):
            path_list += get_paths(p, bot)
    for u in path_list:
        u.append(top)
    return path_list

For example:

sage: gp = get_paths (Partition([3,3,1]),Partition([2,1])); len(gp)
8
sage: len (get_paths (Partition([3,3,2]),Partition([1])))
42

Actually we are computing functions already defined in Sage:

sage: sst = StandardSkewTableaux([[3, 3, 1], [2, 1]])
sage: sst.cardinality()
8
sage: StandardTableaux([3,3,2]).cardinality()
42

Use sst.list() to get the "same" list as the one computed by get_paths(). And You may eventually look at the source code of these functions ! functions, in the modules sage.combinat.tableau and sage.combinat.skew_tableau .

Amitiés.