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: Jan Koornstra

Jan Koornstra's wiki page.

Jan Koornstra has authored 17 sequences. Here are the ten most recent ones:

A333325 Lexicographically earliest sequence over {0,1,2} that has the shortest square subsequence.

Original entry on oeis.org

0, 1, 0, 2, 0, 1, 0, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 0, 2, 2, 0, 1, 0, 2, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1, 0, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 0, 2, 1, 0, 1, 2, 0, 1, 0, 2, 0, 1, 2, 0, 2, 2, 0, 1, 0, 2, 0, 1, 2
Offset: 0

Author

Jan Koornstra, Mar 15 2020

Keywords

Comments

This is very similar to A333307. See that sequence for details about the precise definition. - N. J. A. Sloane, Nov 29 2020

Examples

			a(7) = 0, since:
0 yields a square subsequence of length 2: [0, 0],
1 of length 4: [0, 1, 0, 1],
2 of length 8: [0, 1, 0, 2, 0, 1, 0, 2].
		

Crossrefs

Programs

  • Python
    def a333325(n):
      seq = []
      for k in range(n):
        options = []
        l = len(seq) + 1
        for m in range(3): # base
          for i in range(l // 2, -1, -1):
            if seq[l - 2 * i: l - i] == seq[l - i:] + [m]: break
          options.append(2 * i)
        seq.append(options.index(min(options)))
      return seq
    print(a333325(81))

A333307 Lexicographically earliest sequence over {0,1,2} that has the shortest palindromic or square subsequence (see Comments for precise definition).

Original entry on oeis.org

0, 1, 2, 0, 1, 1, 2, 0, 0, 1, 2, 0, 1, 1, 2, 2, 0, 1, 2, 0, 0, 1, 2, 2, 0, 1, 2, 0, 2, 2, 1, 0, 2, 1, 1, 0, 2, 2, 1, 0, 2, 1, 2, 2, 0, 1, 2, 0, 0, 1, 2, 2, 0, 1, 2, 0, 2, 2, 1, 0, 2, 1, 1, 0, 2, 2, 1, 0, 0, 2, 1, 0, 2, 2, 1, 0, 0, 0, 2, 1, 0, 2
Offset: 0

Author

Jan Koornstra, Mar 14 2020

Keywords

Comments

Formal definition, from R. J. Mathar, Nov 29 2020: (Start)
Jan Koornstra's Python program does the following:
Consider the given terms a(1),...,a(n-1) and check for all three candidates c=a(n)=0,1,2 the following:
i) Derive the longest palindromic subsequence
a(i),a(i+1),...,a(n-1),c
by chopping initial terms of the sequence, that is,
take the smallest i such that c=a(i), a(n-1)=a(i+1), ...
ii) Derive the longest subsequence which is a square (word)
a(i),a(i+1),...,a(n-1),c
by chopping initial terms of the sequence, that is
take the smallest i such that [a(i),a(i+1),...] = [..., a(n-1),c]
The length of the longer of the two candidate subsequences "dominates" and is remembered for each c.
The c (out of the three candidates) where that dominating length is shortest becomes the actual a(n).
So the principle is like selecting 0, 1, or 2 by trying to keep the end of the current sequence as much as possible out of tune with being square or palindromic. (End)

Examples

			a(5) = 1:
  0 yields a palindromic subsequence of length 3: [0, 1, 0],
  1 a square subsequence of length 2: [1, 1],
  and 2 a square subsequence of length 6: [0, 1, 2, 0, 1, 2].
a(6) = 2:
  0 yields a palindromic subsequence of length 4: [0, 1, 1, 0],
  1 a palindromic subsequence of length 3: [1, 1, 1],
  and 2 a palindromic subsequence of length 1: [2]
		

Programs

  • Python
    def a333307(n):
      seq = []
      for k in range(n):
        options = []
        l = len(seq) + 1
        for m in range(3): # base
          palindrome, square = 0, 0
          for i in range(l - 1): # palindrome
            if seq[i::] + [m] == (seq[i::] + [m])[::-1]:
              palindrome = l - i
              break
          for i in range(l // 2, -1, -1): # square
            if seq[l - 2 * i: l - i] == seq[l - i:] + [m]:
              square = 2 * i
              break
          options.append(max(palindrome, square))
        seq.append(options.index(min(options)))
      return seq
    print(a333307(82))

A333311 a(n) is the total number of leaves of a binary tree of depth n on a square grid where each parent-node branches out in the two directions closest to the direction of the edge from which it sprang, either along the grid for even generations or across for odd generations ('L-toothpick'), yet only if the child-nodes' coordinates are not occupied already.

Original entry on oeis.org

2, 4, 7, 12, 19, 29, 41, 56, 71, 90, 109, 133, 155, 183, 209, 242, 271, 309, 340, 384, 418, 466, 505, 555, 600, 651, 703, 758, 813, 874, 931, 999, 1058, 1133, 1195, 1277, 1343, 1432, 1502, 1597, 1671, 1771, 1849, 1954, 2036, 2142
Offset: 1

Author

Jan Koornstra, Mar 14 2020

Keywords

Comments

The branching order is pre-order depth-first search.

Examples

			a(1) = 2, since two branches can be formed from the root-node at (0, 0) across the diagonals of the grid to (-1, 1) and (1, 1) respectively, hence:
Generation 1:      \/
a(2) = 4, yielding new leaves at respectively (-2, 1), (-1, 2), (1, 2) and (2, 1):
Generation 2:    _|  |_
                   \/
a(3) = 7, since the node at (1, 2) cannot branch out, as one of its child-nodes would get coordinates (0, 3), which is already in use by a node branched from (-1, 2).
Generation 3:     \/
                \_|  |_/
                /  \/  \
		

Crossrefs

Cf. A172310.

Programs

  • Python
    used = [[0, 0]] # nodes used in the tree
    nodes = [[0, 0, 0]] # x, y, direction
    gen = 0
    terminations = [0]
    leaves = [1]
    directions = [[[-1, 0, 0, 1], [0, 1, 1, 0], [1, 0, 0, -1], [0, -1, -1, 0]], [[-1, 1, 1, 1], [1, 1, 1, -1], [1, -1, -1, -1], [-1, -1, -1, 1]]] # LU/RU/RD/DL, U/R/D/L
    while gen < 100:
      terminations.append(0)
      length = len(nodes)
      for n in range(length):
        x1 = nodes[n][0] + directions[(gen+1)%2][nodes[n][2]][0]
        y1 = nodes[n][1] + directions[(gen+1)%2][nodes[n][2]][1]
        x2 = nodes[n][0] + directions[(gen+1)%2][nodes[n][2]][2]
        y2 = nodes[n][1] + directions[(gen+1)%2][nodes[n][2]][3]
        if [x1, y1] not in used and [x2, y2] not in used:
          nodes += [[x1, y1, (nodes[n][2] - gen%2)%4]]
          nodes += [[x2, y2, (nodes[n][2] + (gen+1)%2)%4]]
          used += [[x1, y1], [x2, y2]]
          leaves[gen] += 1
        else:
          terminations[gen] += 1
      nodes = nodes[length:]
      gen += 1
      leaves.append(leaves[-1])
    print(leaves[:-1]) # This sequence.
    print(terminations[:-1])

A309899 Numbers k = 1, 2, 3, ... are added to the sequence along with k blanks. Next, the numbers k + 1 are inserted on the blanks along with k + 1 blanks. This process is then repeated.

Original entry on oeis.org

1, 2, 2, 3, 4, 3, 3, 5, 6, 4, 4, 4, 7, 8, 5, 5, 9, 5, 5, 10, 6, 6, 11, 12, 6, 6, 6, 7, 7, 13, 14, 8, 7, 7, 15, 8, 7, 7, 16, 9, 17, 8, 8, 18, 9, 10, 8, 8, 8, 19, 20, 9, 9, 11, 10, 21, 22, 9, 9, 12, 9, 9, 10, 10, 23, 11, 24, 13, 25, 10, 10, 11, 26
Offset: 1

Author

Jan Koornstra, Aug 21 2019

Keywords

Examples

			The first elements are:
  1 _ 2 _ _ 3 _ _ _ 4 _ _ _ _ 5 _ _ _ _ _
    2   _ _   3 _ _   _ 4 _ _   _ _ 5 _ _
        3 _     _ _   4   _ _   _ _   5 _
          4     _ _       _ _   5 _     _
                5 _       _ _     _     _
                  .
  1 2 2 3 4 3 3 5 6 4 4 4 7 8 5 5 9 5 5 10
		

Crossrefs

Programs

  • Python
    seq = []
    for n in range(1, 100): seq += [n] + n*[-1]
    for n in range(2, len(seq)):
      value = n
      gaps = 0
      position = n - 1
      while position < len(seq):
        if seq[position] == -1:
          if gaps > 0: gaps -= 1
          else:
            seq[position] = value
            gaps = value
            value += 1
        position += 1
    print(seq)

A309898 For each b = 1, 2, 3, ... numbers k = 1, 2, 3, ... are inserted into the blanks within the sequence along with k * b blanks, skipping existing terms in the sequence.

Original entry on oeis.org

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

Author

Jan Koornstra, Aug 21 2019

Keywords

Comments

b = 1 for all blanks forms A003602. b = k yields A002260.

Examples

			The first 21 terms are constructed as follows:
  1 _ 2 _ _ 3 _ _ _ 4 _ _ _ _ 5 _ _ _ _ _ .
    1   _ _   2 _ _   _ _ 3 _   _ _ _ _ _ .
        1 _     _ _   2 _   _   _ _ _ _ 3 .
          1     _ _     _   _   2 _ _ _   .
                1 _     _   _     _ _ 2   .
                  1     _   _     _ _     .
                        1   _     _ _     .
                            1     _ _     .
                                  1 _     .
                                    1     .
  1 1 2 1 1 3 2 1 1 4 2 1 3 1 5 2 1 1 2 3 .
		

Crossrefs

Programs

  • Python
    seq = []
    b = 2
    for n in range(1, 100):
      seq += [n] + [-1] * n
    while -1 in seq:
      i = seq.index(-1)
      seq[i] = 1
      k = 2
      blanks = b
      for s in range(i + 1, len(seq)):
        if seq[s] == -1:
          blanks -= 1
          if blanks < 0:
            seq[s] = k
            blanks = k * b
            k += 1
      b += 1
    print(seq)

A307344 Cells visited by a single pawn move for an even cell and a double pawn move for an odd cell on a numbered 3D grid and moving to the lowest available unvisited cell of different parity at each step.

Original entry on oeis.org

1, 10, 19, 48, 27, 76, 51, 20, 33, 8, 15, 4, 9, 34, 53, 108, 77, 28, 13, 2, 5, 30, 47, 18, 31, 6, 3, 12, 23, 72, 49, 102, 71, 22, 11, 36, 21, 70, 101, 186, 131, 252, 193, 106, 75, 26, 43, 16
Offset: 1

Author

Jan Koornstra, Apr 02 2019

Keywords

Comments

The grid is numbered as follows:
1: [0, 0, 0]
-- 1 step --
2: [0, 0, 1]
3: [0, 1, 0]
4: [1, 0, 0]
-- 2 steps --
5: [0, 0, 2]
6: [0, 1, 1]
7: [0, 2, 0]
8: [1, 0, 1]
9: [1, 1, 0]
10: [2, 0, 0]
etc.

Examples

			1: [0, 0, 0] is an odd cell, hence a double move is required. Since 5: [0, 0, 2] and 7: [0, 2, 0] are also odd, 10: [2, 0, 0] is the only valid move.
The sequence ends at 16: [1, 1, 1]. A single move is required, which limits the possible destination cells to:
   6: [0, 1, 1], even;
   8: [1, 0, 1], even;
   9: [1, 1, 0], already visited;
  27: [1, 1, 2], already visited;
  28: [1, 2, 1], even;
  31: [2, 1, 1], already visited;
		

Crossrefs

A307326 Rightmost terms of A307226.

Original entry on oeis.org

0, 1, 2, 8, 148, 10728, 426548, 6709112
Offset: 1

Author

Jan Koornstra, Apr 02 2019

Keywords

Comments

No additional values below 10^7. - Bert Dobbelaere, Jul 10 2019

Crossrefs

Cf. A307226.

Extensions

a(7)-a(8) from Bert Dobbelaere, Jul 10 2019

A307226 Triangle read by rows: drop and bounce.

Original entry on oeis.org

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

Author

Jan Koornstra, Mar 31 2019

Keywords

Comments

Number k starts with 1, 2, 3, ... 'points' and is 'dropped' on the initial value of 0. k then 'bounces' on the numbers already in the sequence according to the following rules:
- k loses 1 point for each bounce.
- After the first bounce (i.e., on 0) k moves to the right. If k bounces on a number already in the sequence which has a higher value than k, then the direction reverses. At lower or equal values, k continues to move in the same direction.
- If k reaches the start or the end of the sequence or has 0 points left, the starting value of k is added to the sequence at that position.

Examples

			For k = 4:
4 points, bounce on 0, move to the right;
3 points, bounce on 1, move to the right;
2 points, bounce on 3, reverse direction;
1 point, bounce on 1, move to the left;
0 points: k = 4 is inserted between 0 and 1. (Although equal to the next value 0, k has no more points left to bounce over it.)
The first iterations:
  [0];
  [0, 1];
  [0, 1, 2];
  [0, 1, 3, 2];
  [0, 4, 1, 3, 2];
  [0, 4, 5, 1, 3, 2];
  [0, 4, 6, 5, 1, 3, 2];
  [7, 0, 4, 6, 5, 1, 3, 2];
  [7, 0, 4, 6, 5, 1, 3, 2, 8];
  ...
		

Crossrefs

Cf. A307326.

Programs

  • PARI
    process(row, n) = {my(pos = 1, dir = 1, m = n); while (m && (pos >= 1) && (pos <= #row), if (m < row[pos], dir = -dir); pos += dir; m--;); if (pos == 0, return (concat(n, row))); if (pos == #row +1, return (concat(row, n))); if (dir == -1, pos ++); my(nrow = vector(#row+1)); for (k=1, pos-1, nrow[k] = row[k];); nrow[pos] = n; for (k = pos+1, #row+1, nrow[k] = row[k-1];); return (nrow);}
    tabl(nn) = {row = [0]; print(row); for (n=1, nn, row = process(row, n); print(row););} \\ Michel Marcus, Apr 13 2019
  • Python
    seq = [0]
    for k in range (1, 10):
      points = k
      position = seq.index(0)
      direction = 1
      while points > 0 and position >= 0 and position < len(seq):
        if points < seq[position]: direction *= -1
        points -= 1
        position += direction
      else:
        if position < 0: seq.insert(0, k)
        elif position == len(seq): seq.append(k)
        elif points == 0 and direction == 1: seq.insert(position, k)
        else: seq.insert(position - direction, k)
    print(seq)
    

A324275 Numbers k for which A324274(k) is 0, i.e., starting squares in A324274 that yield a path of infinite length.

Original entry on oeis.org

2, 9, 14, 27, 34, 53, 64, 89, 102, 133, 150, 187, 206, 249, 272, 321, 346, 401, 430, 491, 522, 589, 624, 697, 734, 813, 854, 939, 982, 1073, 1120, 1217, 1266, 1369, 1422, 1531, 1586, 1701, 1760, 1881, 1942, 2069, 2134, 2267, 2334, 2473
Offset: 1

Author

Jan Koornstra, Feb 27 2019

Keywords

Comments

Note that the sequence up to a(n) (for its current known values) is actually the path of a(n) in reverse until it reaches square 2. It is therefore conjectured that all starting squares in A324274 either have a finite length or are part of this single sequence.

Crossrefs

Formula

Conjectures from Colin Barker, Mar 09 2019: (Start)
G.f.: x*(2 + 7*x + 3*x^2 + 6*x^3 - x^5 + x^6) / ((1 - x)^3*(1 + x)^2*(1 + x^2)).
a(n) = (5 + 7*(-1)^n + (2-2*i)*(-i)^n + (2+2*i)*i^n + (26+6*(-1)^n)*n + 18*n^2) / 16 where i=sqrt(-1).
a(n) = a(n-1) + a(n-2) - a(n-3) + a(n-4) - a(n-5) - a(n-6) + a(n-7) for n>7.
(End)

A324274 a(n) is the number of squares visited by a single pawn move for an even square and a double pawn move for an odd square on a diagonally numbered board and moving to the lowest available unvisited square of different parity at each step from subsequent starting squares n; or a(n) = 0 for an infinite length.

Original entry on oeis.org

20, 0, 8, 17, 6, 9, 4, 7, 0, 11, 16, 5, 18, 0, 10, 19, 8, 19, 8, 11, 12, 25, 6, 9, 6, 9, 0, 13, 24, 7, 20, 7, 20, 0, 12, 15, 24, 21, 26, 21, 10, 21, 10, 13, 14, 27, 8, 27, 8, 11, 8, 11, 0, 15, 16, 33, 22, 9, 22, 9, 22, 9, 22, 0, 14, 17, 32, 23
Offset: 1

Author

Jan Koornstra, Feb 20 2019

Keywords

Comments

It is conjectured that all starting squares will either have a finite length or reach the top row of the board at square 2 first and then follow the sequence for a(2) to infinity. A324275 contains numbers n for which A324274(n) = 0.

Examples

			a(1) is the length of A324273. a(2) has an infinite length as it will follow a repeating pattern along the top row of the numbered board.
		

Crossrefs