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.

Showing 1-3 of 3 results.

A335973 The Locomotive Pushing or Pulling its Wagons sequence (see comments for definition).

Original entry on oeis.org

13, 24, 35, 46, 57, 68, 791, 202, 14, 25, 36, 47, 58, 691, 203, 15, 26, 37, 48, 591, 204, 16, 27, 38, 491, 205, 17, 28, 391, 206, 18, 291, 207, 181, 208, 191, 302, 131, 2002, 135, 461, 303, 141, 304, 151, 305, 161, 306, 171, 307, 182, 31, 2003, 142, 308, 192, 41, 2004, 152, 313, 241, 2005, 162, 51, 402
Offset: 1

Views

Author

Eric Angelini and Carole Dubois, Jul 03 2020

Keywords

Comments

a(1) is the locomotive; a(2), a(3), a(4),... a(n),... are the wagons. To hook a wagon both to its predecessor (on the left) and successor (on the right) you must be able to insert the leftmost digit of a(n) between the last two digits of a(n-1) AND to insert the rightmost digit of a(n) between the first two digits of a(n+1). In mathematical terms, the value of the leftmost digit of a(n) must be between (not equal to) the last two digits of a(n-1) AND the value of the rightmost digit of a(n) must be between (not equal to) the first and the second digit of a(n+1). This is the lexicographically earliest sequence of distinct positive terms with this property.
a(n) cannot end in 0 or 9. - Michael S. Branicky, Dec 14 2020

Examples

			The sequence starts with 13, 24, 35, 46, 57, 68, 791, 202, 14,...
a(1) = 13 as there is no earliest possible locomotive;
a(2) = 24 starts with 2 and 4: now 2 < 3 < 4 [3 being the rightmost digit of a(1)] AND 3 < 4 < 5 [4 being the rightmost digit of a(2), 3 and 5 being the first two digits of a(3)];
a(3) = 35 starts with 3 and 5: now 3 < 4 < 5 [4 being the rightmost digit of a(2)] AND 4 < 5 < 6 [5 being the rightmost digit of a(3), 4 and 6 being the first two digits of a(4)];
a(4) = 46 starts with 4 and 6: now 4 < 5 < 6 [5 being the rightmost digit of a(3)] AND 5 < 6 < 7 [6 being the rightmost digit of a(4), 5 and 7 being the first two digits of a(5)];
a(5) = 57 starts with 5 and 7: now 5 < 6 < 7 [6 being the rightmost digit of a(4)] AND 6 < 7 < 8 [7 being the rightmost digit of a(5), 6 and 8 being the first two digits of a(6)];
a(6) = 68 starts with 6 and 8: now 6 < 7 < 8 [7 being the rightmost digit of a(5)] AND 7 < 8 < 9 [8 being the rightmost digit of a(6), 7 and 9 being the first two digits of a(7)];
a(7) = 791 starts with 7 and 9: now 7 < 8 < 9 [8 being the rightmost digit of a(6)] AND 2 > 1 > 0 [1 being the rightmost digit of a(7); 2 and 0 being the first two digits of a(8)]; etc.
		

Crossrefs

Cf. A335971 (locomotive pulling to the left) and A335972 (locomotive pushing to the right).

Programs

  • Python
    def between(i, j, k):
      return i < j < k or i > j > k
    def dead_end(k):
      rest, last = divmod(k, 10)
      if last in {0, 9}: return True
      return abs(rest%10 - last) <= 1
    def aupto(n, seed=13):
      train, used = [seed], {seed}
      for n in range(2, n+1):
        caboose = train[-1]
        cabbody, cabhook = divmod(caboose, 10)
        h1, h2 = sorted([cabbody%10, cabhook])
        hooks = set(range(h1+1, h2))
        pow10 = 10
        an = min(hooks)*pow10
        while an in used or dead_end(an): an += 1
        hook = an//pow10
        while True:
          if hook in hooks:
            if between(hook, cabhook, an//(pow10//10)%10):
              train.append(an)
              used.add(an)
              break
          else: pow10 *= 10
          an = max(an+1, min(hooks)*pow10)
          while an in used or dead_end(an): an += 1
          hook = an//pow10
      return train    # use train[n-1] for a(n)
    print(aupto(65))  # Michael S. Branicky, Dec 14 2020

A335971 The Locomotive Pulling the Wagons to the Left sequence (see Comments lines for definition).

Original entry on oeis.org

13, 20, 14, 24, 30, 15, 25, 31, 26, 35, 40, 16, 27, 36, 41, 28, 37, 42, 38, 46, 50, 17, 29, 39, 47, 51, 48, 52, 49, 53, 402, 18, 57, 60, 19, 58, 61, 59, 62, 302, 102, 103, 104, 105, 106, 107, 63, 403, 108, 64, 502, 109, 68, 70, 69, 71, 202, 113, 203, 114, 204, 115, 205, 116, 206
Offset: 1

Views

Author

Eric Angelini and Carole Dubois, Jul 03 2020

Keywords

Comments

a(1) is the locomotive; a(2), a(3), a(4),... a(n),... are the successive wagons. To hook a wagon to its predecessor (on the left) you must be able to insert the leftmost digit of a(n) between the last two digits of a(n-1). In mathematical terms, the value of the leftmost digit of a(n) must be between (not equal to) the penultimate and the last digit of a(n-1). This is the lexicographically earliest sequence of distinct positive terms with this property.

Examples

			The sequence starts with 13, 20, 14, 24, 30,...
a(1) = 13 as there is no earliest possible (pulling to the left) locomotive;
a(2) = 20 starts with 2 and 1 < 2 < 3 [1 and 3 being the last two digits of a(1)];
a(3) = 14 starts with 1 and 2 > 1 > 0 [2 and 0 being the last two digits of a(2)];
a(4) = 24 starts with 2 and 1 < 2 < 4 [1 and 4 being the last two digits of a(3)]; etc.
		

Crossrefs

Cf. A335972 (locomotive pushing to the right) and A335973 (two locomotives).

Programs

  • Python
    def dead_end(k): return abs((k//10)%10 - k%10) <= 1
    def aupto(n, seed=13):
      train, used = [seed], {seed}
      for n in range(2, n+1):
        caboose = train[-1]
        h1, h2 = sorted([(caboose//10)%10, caboose%10])
        hooks = set(range(h1+1, h2))
        pow10 = 10
        an = min(hooks)*pow10
        while an in used: an += 1
        hook = an//pow10
        while True:
          if hook in hooks:
            if not dead_end(an):
              train.append(an)
              used.add(an)
              break
          else: pow10 *= 10
          an = max(an+1, min(hooks)*pow10)
          while an in used: an += 1
          hook = an//pow10
      return train    # use train[n-1] for a(n)
    print(aupto(65))  # Michael S. Branicky, Dec 14 2020

A339467 The Ronnie O'Sullivan's "infinite plant" sequence: nonprime numbers become prime numbers by striking the cue ball 1 with a cue stick to the right (see the Comments section).

Original entry on oeis.org

1, 12, 4, 14, 15, 6, 16, 18, 32, 8, 33, 9, 72, 34, 35, 36, 74, 38, 39, 75, 91, 76, 77, 92, 93, 78, 94, 192, 95, 96, 132, 98, 99, 111, 133, 112, 114, 194, 195, 212, 115, 213, 116, 134, 196, 135, 214, 198, 117, 272, 118, 119, 291, 136, 138, 215, 216, 171, 273, 172, 231, 274, 217, 275, 218, 219, 292, 232, 234, 312, 235
Offset: 1

Views

Author

Eric Angelini and Carole Dubois, Dec 06 2020

Keywords

Comments

There is a non-snooker description of this sequence: first erase all spaces between terms; then move every comma 1 position to the left; the new sequence is now made by primes only (with duplicates, sometimes); the starting sequence (this one) is the lexicographically earliest with this property that has no duplicates and no primes.

Examples

			Striking 1 to the right pushes 1 against 12;
the last digit of 12 is then pushed against 4 (leaving 11 behind - a prime);
the last digit of 4 is then pushed against 14 (leaving 2 behind - a prime);
the last digit of 14 is then pushed against 15 (leaving 41 behind - a prime);
the last digit of 15 is then pushed against 6 (leaving 41 behind - a prime);
the last digit of 6 is then pushed against 16 (leaving 5 behind - a prime); etc.
This is the lexicographically earliest sequence of distinct positive terms with this property
		

Crossrefs

Cf. A339616 (the Judd Trump sequence), A335972, A335973.

Programs

  • Python
    from sympy import isprime
    def aupto(n):
        alst, used = [0, 1], {1}
        for k in range(2, n+1):
            ball = (str(alst[k-1]))[-1]
            ak = 1
            ball_left = ball + (str(ak))[:-1]
            while not isprime(int(ball_left)) or ak in used or isprime(ak):
                ak += 1 + (ak%10 == 9)  # can't end in 0
                ball_left = ball + (str(ak))[:-1]
            alst.append(ak)
            used.add(ak)
        return alst[1:]  # use alst[n] for a(n) function
    print(aupto(64))  # Michael S. Branicky, Dec 07 2020
Showing 1-3 of 3 results.