A335971 The Locomotive Pulling the Wagons to the Left sequence (see Comments lines for definition).
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
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.
Links
- Carole Dubois, Table of n, a(n) for n = 1..5001
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
Comments