A358838 Minimum number of jumps needed to go from slab 0 to slab n in Jane Street's infinite sidewalk.
0, 1, 2, 5, 3, 6, 9, 4, 7, 10, 10, 5, 8, 8, 11, 11, 11, 6, 14, 9, 9, 12, 12, 12, 15, 12, 7, 18, 15, 10, 10, 10, 13, 13, 13, 13, 16, 16, 13, 16, 8, 19, 19, 16, 11, 11, 11, 11, 19, 14, 14, 14, 14, 14, 22, 17, 17, 17, 14, 17, 17, 9, 20, 20, 20, 17, 17, 12, 12, 12
Offset: 0
Keywords
Examples
For n=0, a(0) = 0 since it takes zero jump to go from slab 0 to slab 0. For n=3, a(3) = 5 jumps is the minimum needed to go from slab 0 to slab 3: . 1st 2nd 3rd 4th jump jump jump jump ->- ->- ---->---- ------->------- / \ / \ / \ / \ n 0 1 2 3 4 5 6 7 8 ... L(n) 1 1 2 2 3 3 4 4 5 ... \ / ----------<---------- 5th jump (backwards)
Links
- Neal Gersh Tolunsky, Table of n, a(n) for n = 0..10000
- Atlantis, Infinite sidewalk blog post.
- Jane Street, Numberphile webpage.
Crossrefs
Programs
-
Python
def a(n: int) -> int: import itertools if n < 0: raise Exception("n must be a nonnegative integer") if n == 0: return 0 if n == 1: return 1 visited = {0, 1} # the slabs we have visited so far rings = [{0}, {1}] # the slabs ordered by depth (min length of path from 0) for depth in itertools.count(2): new_ring = set() for slab in rings[depth - 1]: label = (slab >> 1) + 1 for next_slab in {slab - label, slab + label}: if not next_slab in visited: if next_slab == n: return depth visited.add(next_slab) new_ring.add(next_slab) rings.append(new_ring)
Comments