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.

User: Hector J. Partridge

Hector J. Partridge's wiki page.

Hector J. Partridge has authored 3 sequences.

A289832 Triangle read by rows: T(n,k) = number of rectangles all of whose vertices lie on an (n+1) X (k+1) rectangular grid.

Original entry on oeis.org

1, 3, 10, 6, 20, 44, 10, 33, 74, 130, 15, 49, 110, 198, 313, 21, 68, 152, 276, 443, 640, 28, 90, 200, 364, 592, 866, 1192, 36, 115, 254, 462, 756, 1113, 1550, 2044, 45, 143, 314, 570, 935, 1385, 1944, 2586, 3305, 55, 174, 380, 688, 1129, 1680, 2370, 3172, 4081, 5078
Offset: 1

Author

Hector J. Partridge, Jul 13 2017

Keywords

Comments

T(n,k) is the number of rectangles (including squares) that can be drawn on an (n+1) X (k+1) grid.
The diagonal of T(n,k) is the number of rectangles in a square lattice (A085582), i.e., T(n,n) = A085582(n+1).
Column k=1 equals A000217.
Column k=2 equals A140229 for n >= 3 as the only oblique rectangles are squares of side length sqrt(2), leading to the same formula.

Examples

			Triangle T(n,k) begins:
n/k  1    2    3    4     5     6     7     8     9    10
1    1
2    3   10
3    6   20   44
4   10   33   74  130
5   15   49  110  198   313
6   21   68  152  276   443   640
7   28   90  200  364   592   866  1192
8   36  115  254  462   756  1113  1550  2044
9   45  143  314  570   935  1385  1944  2586  3305
10  55  174  380  688  1129  1680  2370  3172  4081  5078
e.g., there are T(3,3) =  44 rectangles in a 4 X 4 lattice:
There are A096948(3,3) = 36 rectangles whose sides are parallel to the axes;
There are 4 squares with side length sqrt(2);
There are 2 squares with side length sqrt(5);
There are 2 rectangles with side lengths sqrt(2) X 2 sqrt(2).
		

Crossrefs

Programs

  • Python
    from math import gcd
    def countObliques(a,b,c,d,n,k):
        if(gcd(a, b) == 1): #avoid double counting
            boundingBox={'width':(b * c) + (a * d),'height':(a * c) + (b * d)}
            if(boundingBox['width']A096948
        ret=(n*(n-1)*k*(k-1))/4
        #oblique rectangles
        ret+=sum(countObliques(a,b,c,d,n,k) for a in range(1,n) \
                                            for b in range(1,n) \
                                            for c in range(1,k) \
                                            for d in range(1,k))
        return ret
    Tnk=[[totalRectangles(n+1,k+1) for k in range(1, n+1)] for n in range(1, 20)]
    print(Tnk)

A283241 Triangle read by rows: S(n,k) = total number of directed self-avoiding walks (SAWs) of length k in an n-ladder graph.

Original entry on oeis.org

2, 2, 4, 8, 8, 8, 6, 14, 20, 28, 20, 16, 8, 20, 32, 52, 56, 64, 40, 28, 10, 26, 44, 76, 96, 132, 128, 128, 72, 44, 12, 32, 56, 100, 136, 204, 240, 296, 264, 232, 120, 64, 14, 38, 68, 124, 176, 276, 356, 492, 548, 608, 504, 392, 188, 88
Offset: 1

Author

Hector J. Partridge, Mar 03 2017

Keywords

Comments

n is the number of rows in the ladder graph, i.e., L_n.
k is the length of the directed SAWs. k = 0 represents the single nodes with no edges.
S(n,k) is the number of distinct SAWs of length k in the n-ladder graph.

Examples

			Triangle S(n,k) begins:
n/k  0   1    2    3    4    5    6     7     8     9    10    11    12    13    14    15    16    17   18   19
1    2   2
2    4   8    8    8
3    6  14   20   28   20   16
4    8  20   32   52   56   64   40    28
5   10  26   44   76   96  132  128   128    72    44
6   12  32   56  100  136  204  240   296   264   232   120    64
7   14  38   68  124  176  276  356   492   548   608   504   392   188    88
8   16  44   80  148  216  348  472   692   864  1104  1168  1172   904   628   280   116
9   18  50   92  172  256  420  588   892  1184  1636  1984  2352  2352  2148  1540   964   400   148
10  20  56  104  196  296  492  704  1092  1504  2172  2840  3720  4352  4800  4512  3772  2512  1428  552  184
e.g., there are T(3,3) = 28 directed SAWs of length 3 in L_3.
Fourteen shapes walked in both directions:
>   _          _
>  |     |      |      |    |_      _|
>  |     |_     |     _|      |    |
>                 _    . .    _     _   . .  . .
>  |_|    . .    | |    _    |_     _|   _    _
>  . .    |_|    . .   | |   . .   . .  |_    _|
		

Crossrefs

Uses A283240 for the number of n-ladders with no empty rows.
The right diagonal is the number of directed Hamiltonian paths in the n-ladder graph (A137882).

Programs

  • Python
    # As A283240 but Tnk initialized as grid instead of a triangle
    maxN=20
    Tnk=[[0 for column in range(0, maxN*2)] for row in range(0, maxN+1)]
    Tnk[1][0]=2 # initial values for the special case of 1-ladder.  Two single nodes.
    Tnk[1][1]=2 # SAW of length 1 on a L_1, either left or right
    for row in range(2, maxN+1):
        for column in range(0, row*2):
            if(column+1 < row):
                # path is smaller than ladder - no possible SAW using all rows
                Tnk[row][column] = 0
            elif(column+1 == row):
                # vertical SAW, 2 possible in 2 directions
                Tnk[row][column] = 4
            elif(column == row*2 -1):
                # n-ladder Hamiltonian A137882
                Tnk[row][column] = 2*(row*row - row + 2)
            elif(column == 2*(row-1)):
                # Grow SAW including Hamiltonians from previous row, 4 extra SAWs from Hamiltonians
                Tnk[row][column] = Tnk[row-1][column-1] + Tnk[row-1][column-2] + 4
            else:
                # Grow SAW from previous SAWs. Either adding one or two edges
                Tnk[row][column] = Tnk[row-1][column-1] + Tnk[row-1][column-2]
    # Sum multiples of the columns above this one e.g. T(n,k) + 2T(n,k-1) + 3T(n,k-2) + ...
    Snk=[[0 for column in range(0,row*2)] for row in range(0,maxN+1)]
    for row in range(1,maxN+1):
        for column in range(0,(row*2)):
            for i in range(0,row):
                Snk[row][column]+=(i+1)*Tnk[row-i][column]
    print(Snk)

Formula

Using T(n,k) from A283240,
S(n,k) = T(n,k) + 2*T(n,k-1) + 3*T(n,k-2) + 4*T(n,k-4) + ... + (k+1)*T(n,0)

A283240 Triangle read by rows: T(n,k) = number of directed self-avoiding walks (SAWs) of length k in an n-ladder graph that use all rows of the graph.

Original entry on oeis.org

2, 2, 0, 4, 8, 8, 0, 0, 4, 12, 20, 16, 0, 0, 0, 4, 16, 32, 40, 28, 0, 0, 0, 0, 4, 20, 48, 72, 72, 44, 0, 0, 0, 0, 0, 4, 24, 68, 120, 144, 120, 64, 0, 0, 0, 0, 0, 0, 4, 28, 92, 188, 264, 264, 188, 88, 0, 0, 0, 0, 0, 0, 0, 4, 32, 120, 280, 452, 528, 452, 280, 116
Offset: 1

Author

Hector J. Partridge, Mar 03 2017

Keywords

Comments

n is the number of rows in the ladder graph, i.e., L_n.
k is the length of the directed SAWs. k = 0 represents the single nodes with no edges.
T(n,k) is the number of directed SAWs which use at least one node from every row.

Examples

			Triangle T(n,k) begins:
n/k 0  1  2   3   4   5   6   7    8     9  10   11   12    13    14    15    16    17   18   19
1   2  2
2   0  4  8   8
3   0  0  4  12  20  16
4   0  0  0   4  16  32  40  28
5   0  0  0   0   4  20  48  72   72   44
6   0  0  0   0   0   4  24  68  120  144  120   64
7   0  0  0   0   0   0   4  28   92  188  264  264  188    88
8   0  0  0   0   0   0   0   4   32  120  280  452  528   452   280   116
9   0  0  0   0   0   0   0   0    4   36  152  400  732   980   980   732   400   148
10  0  0  0   0   0   0   0   0    0    4   40  188  552  1132  1712  1960  1712  1132  552  184
e.g., there are T(3,3) = 12 directed SAWs of length 3 in L_3 that use at least one node from each row.
Six shapes walked in both directions.
>    _          _
>   |     |      |      |    |_      _|
>   |     |_     |     _|      |    |
		

Crossrefs

The sum of each columns is twice A038577.
The diagonal T(n,2n-1) are the number of directed Hamiltonian paths in the n-ladder graph A137882.
Primarily used to calculate the total number of directed SAWs of length k in an n-ladder A283241.

Programs

  • Python
    maxN=20
    Tnk=[[0 for column in range(0, row*2)] for row in range(0,maxN+1)]
    Tnk[1][0]=2 # initial values for the special case of 1-ladder.  Two single nodes.
    Tnk[1][1]=2 # SAW of length 1 on a L_1, either left or right
    for row in range(2,maxN+1):
        for column in range(0, row*2):
            if(column+1 < row):
                # path is smaller than ladder - no possible SAW using all rows
                Tnk[row][column] = 0
            elif(column+1 == row):
                # vertical SAW, 2 possible in 2 directions
                Tnk[row][column] = 4
            elif(column == row*2 -1):
                # n-ladder Hamiltonian A137882
                Tnk[row][column] = 2*(row*row - row + 2)
            elif(column == 2*(row-1)):
                # Grow SAW including Hamiltonians from previous row, 4 extra SAWs from Hamiltonians
                Tnk[row][column] = Tnk[row-1][column-1] + Tnk[row-1][column-2] + 4
            else:
                # Grow SAW from previous SAWs. Either adding one or two edges
                Tnk[row][column] = Tnk[row-1][column-1] + Tnk[row-1][column-2]
    print(Tnk)

Formula

T(n,k) = 0 when k+1 < n
T(n,k) = 4 when k+1 = n
T(n,k) = 2(n^2-n+2) when k = 2n-1
T(n,k) = T(n-1,k-1) + T(n-1,k-2) + 4 when k = 2n-2
T(n,k) = T(n-1,k-1) + T(n-1,k-2) otherwise