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.

A332662 Put-and-count: An enumeration of N X N where N = {0, 1, 2, ...}. The terms are interleaved x and y coordinates. Or: A row-wise storage scheme for sequences of regular triangles.

Original entry on oeis.org

0, 0, 0, 1, 1, 0, 2, 0, 0, 2, 1, 1, 2, 1, 3, 0, 4, 0, 5, 0, 0, 3, 1, 2, 2, 2, 3, 1, 4, 1, 5, 1, 6, 0, 7, 0, 8, 0, 9, 0, 0, 4, 1, 3, 2, 3, 3, 2, 4, 2, 5, 2, 6, 1, 7, 1, 8, 1, 9, 1, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 0, 5, 1, 4, 2, 4, 3, 3, 4, 3, 5, 3, 6, 2, 7, 2
Offset: 0

Views

Author

Peter Luschny, Feb 18 2020

Keywords

Comments

Other enumerations of N X N designed with storage allocation for extensible arrays in mind include A319514 and A319571.

Examples

			Illustrating the linear storage layout of a sequence of regular triangles.
(A) [ 0], [ 2,  3], [ 7,  8,  9], [16, 17, 18, 19], [30, 31, 32, 33, 34], ...
(B) [ 1], [ 5,  6], [13, 14, 15], [26, 27, 28, 29], ...
(C) [ 4], [11, 12], [23, 24, 25], ...
(D) [10], [21, 22], ...
(E) [20], ...
...
The first column is A000292.
The start values of all partial rows (in ascending order) are 0 plus A014370.
The start values of the partial rows in the first row are A005581 (without first 0).
The start values of the partial rows on the main diagonal are A331987.
The end values of all partial rows (in ascending order) are A332023.
The end values of the partial rows in the first row are A062748.
The end values of the partial rows on the main diagonal are A332698.
		

Crossrefs

A332663 (x-coordinates), A056559 (y-coordinates).

Programs

  • Julia
    function a_list(N)
        a = Int[]
        for n in 1:N
            i = 0
            for j in ((k:-1:1) for k in 1:n)
                t = n - j[1]
                for m in j
                    push!(a, i, t)
                    i += 1
    end end end; a end
    a_list(5) |> println
  • Maple
    count := (k, A) -> ListTools:-Occurrences(k, A): t := n -> n*(n+1)/2:
    PutAndCount := proc(N) local L, n, v, c, seq; L := NULL; seq := NULL;
    for n from 1 to N do
       for v from 0 to t(n)-1 do
         # How often did you see v in this sequence before?
         c := count(v, [seq]);
         L := L, v, c; seq := seq, v;
    od od; L end:  PutAndCount(6);
    # Returning 'seq' instead of 'L' gives the x-coordinates (A332663).
  • Mathematica
    t[n_] := n*(n+1)/2;
    PutAndCount[N_] := Module[{L, n, v, c, seq},
    L = {}; seq = {};
    For[n = 1, n <= N, n++,
       For[v = 0, v <= t[n]-1, v++,
          c = Count[seq, v];
          L = Join[L, {v, c}]; seq = Append[seq, v]
    ]]; L];
    PutAndCount[6] (* Jean-François Alcover, Oct 13 2024, after Maple program *)