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: Frederic Ruget

Frederic Ruget's wiki page.

Frederic Ruget has authored 5 sequences.

A358838 Minimum number of jumps needed to go from slab 0 to slab n in Jane Street's infinite sidewalk.

Original entry on oeis.org

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

Author

Frederic Ruget, Dec 02 2022

Keywords

Comments

Slabs on the sidewalk are numbered n = 0, 1, 2,... and each has a label L(n) = 1, 1, 2, 2, 3, 3,...
At a given slab, a jump can be taken forward or backward by L(n) places (but not back before slab 0).
.
For every n >= 0,
let L(n) = 1 + floor(n/2) -- the label on slab n,
let forward(n) = n + L(n) -- jumping forward,
if n > 0, let backward(n) = n - L(n) -- jumping backward,
let lambda(n) = floor((2/3)*n),
let mu(n) = 1 + 2*n,
let nu(n) = 2 + 2*n.
Observe that given n >= 0, there are exactly two ways of landing onto slab n with a direct jump backwards:
backward-jumping from mu(n) to n, and
backward-jumping from nu(n) to n.
If n is a multiple of 3, there is no other ways of jumping onto slab n. But if n is not a multiple of 3, there is one additional way:
forward-jumping from lambda(n) to n.
(Note that L is A008619, forward(n) == A006999(n+1), lambda is A004523, mu is A005408, nu is A299174.)
.
Every slab n > 0 is reachable from slab 0, since there always exists some slab s < n which reaches n by one or more jumps:
if n != 0 (mod 3), then s = lambda(n) = floor((2/3)*n) takes one forward jump to n,
if n == 0 (mod 3) but n != 0 (mod 9), then s = lambda o lambda o mu(n) = floor((8/9)*n) takes two forward jumps and one backward jump to n,
if n == 0 (mod 9), then s = lambda o lambda o nu(n) = floor((8/9)*n + 6/9) takes two forward jumps and one backward jump to n.
This demonstrates that the sequence never stops.
This also gives the following bounds:
a(n) <= 1 + (4/3)*n,
a(n) <= 6*log(n)/log(9/8).
.
The sequence is a surjective mapping N -> N, since given any n >= 0:
a(forward^n(0)) == n.

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)
		

Crossrefs

Always jumping forwards yields A006999.
In the COMMENTS section, L is A008619, forward(n) == A006999(n+1), lambda is A004523, mu is A005408, nu is A299174.
For related sequences, see A360744-A360746 and A360593-A360595.

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)

A359008 Jane Street's infinite sidewalk's greedy walk inverse mapping.

Original entry on oeis.org

0, 1, 2, 5, 3, 6, 9, 4, 7, 15, 10, 29, 13, 8, 16, 27, 11, 30, 49, 14, 60, 25, 17, 28, 47, 12, 31, 58, 50, 23, 34, 61, 26, 45, 18, 64, 56, 48, 75, 21, 32, 59, 105, 51, 24, 70, 35, 62, 54, 81, 46, 73, 19, 65, 111, 57, 103, 214, 76, 22, 68, 33, 244, 87, 106, 52
Offset: 0

Author

Frederic Ruget, Dec 11 2022

Keywords

Comments

For n a nonnegative integer, a(n) is the smallest nonnegative integer i such that A359005(i) == n.
In fact, if a(n) exists, it is actually the unique nonnegative integer i such that A359005(i) == n. ({A359005(n)} is demonstrably an injective mapping from the nonnegative integers onto themselves.)
It is conjectured that a(n) exists for all nonnegative n. This has been verified true with a computer for all n < 7884654. This would make {a(n)} a one-to-one mapping from the nonnegative integers onto themselves.

References

Crossrefs

Programs

  • Python
    def a(n: int) -> int:
        if n < 0: raise Exception("n must be a nonnegative integer")
        i = 0
        if n == 0: return i
        visited = {0}
        slab = 1
        while True:
            i += 1
            if slab == n: return i
            visited.add(slab)
            label = 1 + (slab >> 1)
            if not slab - label in visited:
                slab -= label  # jumping backwards
            else:
                slab += label  # jumping forwards
                if slab in visited: raise Exception(f"blocked at slab {slab}")

A359005 Jane Street's infinite sidewalk's greedy walk.

Original entry on oeis.org

0, 1, 2, 4, 7, 3, 5, 8, 13, 6, 10, 16, 25, 12, 19, 9, 14, 22, 34, 52, 79, 39, 59, 29, 44, 21, 32, 15, 23, 11, 17, 26, 40, 61, 30, 46, 70, 106, 160, 241, 120, 181, 90, 136, 67, 33, 50, 24, 37, 18, 28, 43, 65, 98, 48, 73, 36, 55, 27, 41, 20, 31, 47, 71, 35, 53
Offset: 0

Author

Frederic Ruget, Dec 10 2022

Keywords

Comments

The Jane Street greedy walk is obtained by starting on slab 0 of Jane Street's infinite sidewalk (see A358838) and always jumping backwards preferably than forwards. Also, it is forbidden to visit a slab more than once.
The sequence is well defined. It demonstrably never ends and never repeats.
It is conjectured that the sequence actually visits all nonnegative integers. This is related to the conjecture that given any positive integer n, there exists a minimal Jane Street's path (i.e., with minimal number of jumps) going from slab 0 to slab n, and ending either in "forwards" or in "forwards-forwards-backwards". This would make the sequence a one-to-one mapping of the nonnegative numbers onto themselves. See also A359008.

Examples

			Let N denote the nonnegative integers.
Let forward and backward denote the forward-jumping and backward-jumping functions as defined in Jane Street's infinite sidewalk rules (see A358838):
  forward(n) = n + floor(n/2) + 1
  backward(n) = n - floor(n/2) - 1
Finally, let f denote the (demonstrably one-to-one) mapping of N x N to N:
  f(i, j) = forward^j(3*i)
The mapping f is illustrated by the following table, where the contents of each cell (i, j) is f(i, j):
.
   \j|
   i\|  0    1    2    3    4    5    6    7    8  ...
  ---+------------------------------------------------
   0 |  0    1    2    4    7   11   17   26   40  ...
   1 |  3    5    8   13   20   31   47   71  107  ...
   2 |  6   10   16   25   38   58   88  133  200  ...
   3 |  9   14   22   34   52   79  119  179  269  ...
   4 | 12   19   29   44   67  101  152  229  344  ...
   5 | 15   23   35   53   80  121  182  274  412  ...
   6 | 18   28   43   65   98  148  223  335  503  ...
   7 | 21   32   49   74  112  169  254  382  574  ...
   8 | 24   37   56   85  128  193  290  436  655  ...
   9 | 27   41   62   94  142  214  322  484  727  ...
  10 | 30   46   70  106  160  241  362  544  817  ...
  11 | 33   50   76  115  173  260  391  587  881  ...
  12 | 36   55   83  125  188  283  425  638  958  ...
  13 | 39   59   89  134  202  304  457  686 1030  ...
  ...| ...  ...  ... ...  ...  ...  ...  ...  ...  ...
(Note that the first row of the table corresponds to A006999.)
.
Equivalently, we can represent f(i, j) as a(n) for some n. This results in the following alternate illustrative table, where the contents of each cell (i, j) is still f(i, j), but represented as a(n):
.
 \j|
 i\| 0       1       2       3       4       5       6       7       8 ...
---+------------------------------------------------------------------------
 0 | a(0)    a(1)    a(2)    a(3)    a(4)    a(29)   a(30)   a(31)   a(32)
 1 | a(5)    a(6)    a(7)    a(8)    a(60)   a(61)   a(62)   a(63)   a(91)
 2 | a(9)    a(10)   a(11)   a(12)   a(75)   a(76)   a(77)   a(78)   a(412)
 3 | a(15)   a(16)   a(17)   a(18)   a(19)   a(20)   a(297)  a(298)  a(1109)
 4 | a(13)   a(14)   a(23)   a(24)   a(44)   a(99)   a(100)  a(258)  a(435)
 5 | a(27)   a(28)   a(64)   a(65)   a(66)   a(67)   a(206)  a(207)  a(208)
 6 | a(49)   a(50)   a(51)   a(52)   a(53)   a(284)  a(285)  a(286)  a(287)
 7 | a(25)   a(26)   a(81)   a(82)   a(83)   a(84)   a(418)  a(419)  a(420)
 8 | a(47)   a(48)   a(103)  a(104)  a(151)  a(152)  a(440)  a(441)  a(442)
 9 | a(58)   a(59)   a(244)  a(245)  a(246)  a(247)  a(248)  a(249)  a(250)
10 | a(34)   a(35)   a(36)   a(37)   a(38)   a(39)   a(958)  a(959)  a(960)
11 | a(45)   a(46)   a(212)  a(213)  a(520)  a(521)  a(522)  a(1455) a(1456)
12 | a(56)   a(57)   a(242)  a(243)  a(290)  a(291)  a(785)  a(786)  a(787)
13 | a(21)   a(22)   a(299)  a(300)  a(301)  a(302)  a(647)  a(648)  a(3437)
.. |
.
The later illustration helps visualize how {a(n)} works: going from a(n) to a(n+1) results in either
  - jumping forwards, thus moving one step to the right in the row of the table, or
  - jumping backwards, thus changing row.
This procedure (demonstrably) never creates a gap in the rows of the table.
		

Crossrefs

A particular valid path on the Jane Street infinite sidewalk A358838.
Possibly the reverse mapping of sequence A359008.
Cf. A006999.

Programs

  • Python
    def a(n: int) -> int:
        if n < 0: raise Exception("n must be a nonnegative integer")
        if n == 0: return 0
        visited = {0}
        slab = 1
        for i in range(1, n):
            label = 1 + (slab >> 1)
            if not slab - label in visited:
                slab -= label  # moving backwards
            else:
                slab += label  # moving forwards
                if slab in visited: raise Exception(f"blocked at slab {slab}")
            visited.add(slab)
        return slab

A345257 Tiefenbruck sequence for the game of countably infinitely many hats.

Original entry on oeis.org

-1, 1, 0, 0, 2, 1, 2, -1, 4, 1, 0, 0, 2, 1, 2, 4, 3, 1, 0, 0, 2, 1, 2, 3, 3, 1, 0, 0, 2, 1, 2, 3, 5, 1, 0, 0, 2, 1, 2, 5, 4, 1, 0, 0, 2, 1, 2, 4, 5, 1, 0, 0, 2, 1, 2, 5, -1, 1, 0, 0, 2, 1, 2, -1, 7, 1, 0, 0, 2, 1, 2, 7, 4, 1, 0, 0, 2, 1, 2, 4, 3, 1, 0, 0, 2, 1
Offset: 0

Author

Frederic Ruget, Jun 12 2021

Keywords

Comments

The Tiefenbruck sequence represents a strategy for the game of countably infinitely many hats. This strategy is conjectured to be one of several optimal strategies.
The rules of the game are as follows: two players each have countably infinitely many hats put on their heads. Each hat is either black or white with equal probability; furthermore, the players are only able to see the hats on the other player's head; simultaneously both players guess and point to a hat on their own head; they win if both pick out a white hat.
One would think that the maximum probability of winning the game is 1/4 -- and indeed the probability of winning is 25% if both players (e.g.) always choose the first hat on their own head. However, better results can be achieved if the players agree on a common strategy.
For example, if both players choose the position of the first black hat on the other player's head, then the probability of success is 1/3. Loosely speaking, this "first black hat" strategy corresponds to A007814 -- in a sense that will be made clearer later on.
Interestingly, choosing the position of the first white hat on the other player's head also results in a probability of success of 1/3. Loosely speaking, this "first white hat" strategy corresponds to A007814, with an added leading -1.
Actually it is possible to achieve a probability of success of 7/20 (35%) using the Tiefenbruck strategy described here, the Carter and Reyes strategy described in A345255, or variations thereof. Also it is an open problem whether strategies can achieve results better than 7/20.
The Tiefenbruck strategy is defined using a cellular automaton specified in the link "Infinitely Many Hats" below. The cellular automaton is fed with the sequence of hats on the other player's head, identifying each black hat with digit 0 and each white hat with digit 1. When (if) it completes, the automaton outputs the position of the hat the player should point to on their own head. Assuming a Baire/Borel measure for the universe of possible hat configurations, then the automaton almost always completes and the probability of success is indeed 7/20.
Now a(n) is defined as the output of the Tiefenbruck cellular automaton when fed with index n -- n being interpreted as the infinite stream of zeros and ones of its binary representation, starting from the least significant bit -- or as -1 if the automaton does not complete with the given infinite stream.
The "Towers of hats" and "Infinitely Many Hats" links below provide a formal exposition of the game of hats and a calculation of the probability of success.

Examples

			With n = 06567700 (octal notation), we have a(n) = 3 + 3 + 3 + 3 + 2 = 14.
		

Crossrefs

Cf. A007814.
Cf. A345255.

Programs

  • JavaScript
    // Tiefenbruck sequence for the game of countably infinitely many hats
    function a(n) {
        let offset = 0;
        while (true) {
            if (n == 0) return -1;
            switch(n & 7) {
                case 1: return offset + 1;
                case 2: return offset + 0;
                case 3: return offset + 0;
                case 4: return offset + 2;
                case 5: return offset + 1;
                case 6: return offset + 2;
            }
            n >>= 3;
            offset += 3;
        }
    }

Formula

[a(n): 0 <= n < 7] = [-1, 1, 0, 0, 2, 1, 2]
For n > 7:
if (n mod 8) in {1, 2, 3, 4, 5, 6}, then a(n) = a(n mod 8);
otherwise if a(floor(n/8)) = -1, then a(n) = -1;
otherwise a(n) = a(floor(n/8)) + 3.

A345255 Carter and Reyes sequence for the game of countably infinitely many hats.

Original entry on oeis.org

-1, 1, 0, 0, 2, 1, 2, 3, 0, 1, 0, 0, 2, 1, 2, 0, 4, 1, 0, 0, 2, 1, 2, 3, 4, 1, 0, 0, 2, 1, 2, 5, 0, 1, 0, 0, 2, 1, 2, 3, 0, 1, 0, 0, 2, 1, 2, 0, 4, 1, 0, 0, 2, 1, 2, 3, 4, 1, 0, 0, 2, 1, 2, 0, 6, 1, 0, 0, 2, 1, 2, 3, 0, 1, 0, 0, 2, 1, 2, 0, 4, 1, 0, 0, 2, 1, 2
Offset: 0

Author

Frederic Ruget, Jun 12 2021

Keywords

Comments

The Carter and Reyes sequence represents a strategy for the game of countably infinitely many hats. This strategy is conjectured to be one of several optimal strategies.
The rules of the game are as follows: two players each have countably infinitely many hats put on their heads. Each hat is either black or white with equal probability; furthermore, the players are only able to see the hats on the other player's head; simultaneously both players guess and point to a hat on their own head; they win if both pick out a white hat.
One would think that the maximum probability of winning the game is 1/4 -- and indeed the probability of winning is 25% if both players (e.g.) always choose the first hat on their own head. However, better results can be achieved if the players agree on a common strategy.
For example, if both players choose the position of the first black hat on the other player's head, then the probability of success is 1/3. Loosely speaking, this "first black hat" strategy corresponds to A007814 -- in a sense that will be made clearer later on.
Interestingly, choosing the position of the first white hat on the other player's head also results in a probability of success of 1/3. Loosely speaking, this "first white hat" strategy corresponds to A007814, with an added leading -1.
Actually it is possible to achieve a probability of success of 7/20 (35%) using the Carter and Reyes strategy described here, the Tiefenbruck strategy described in A345257, or variations thereof. Also it is an open problem whether strategies can achieve results better than 7/20.
The Carter and Reyes strategy is defined using the cellular automaton specified in the link "Infinitely Many Hats" below. The cellular automaton is fed with the sequence of hats on the other player's head, identifying each black hat with digit 0 and each white hat with digit 1. When (if) it completes, the automaton outputs the position of the hat the player should point to on their own head. Assuming a Baire/Borel measure for the universe of possible hat configurations, then the automaton almost always completes and the probability of success is indeed 7/20.
Now a(n) is defined as the output of the Carter and Reyes cellular automaton when fed with index n -- n being interpreted as the infinite stream of zeros and ones of its binary representation, starting from the least significant bit -- or as -1 if the automaton does not complete with the given infinite stream.
The "Towers of hats" and "Infinitely Many Hats" links below provide a formal exposition of the game of hats and a calculation of the probability of success.

Crossrefs

Cf. A007814.
Cf. A345257.

Programs

  • JavaScript
    function a(n) {
        if (n == 0) return -1;
        let offset = 0;
        while (true) {
            switch (n & 7) {
                case 1: return offset + 1;
                case 2: return 0;
                case 3: return 0;
                case 4: return offset + 2;
                case 5: return offset + 1;
                case 6: return offset + 2;
            }
            n = ((n >> 2) & (~1)) | (n & 1);
            offset += 2
        }
    }

Formula

[a(n): 0 <= n < 7] = [-1, 1, 0, 0, 2, 1, 2]
For n >= 7:
if (n mod 8) in {1, 2, 3, 4, 5, 6}, then a(n) = a(n mod 8);
otherwise if n mod 8 = 0, then a(n) = a(2*floor(n/8)) + 2*[a(2*floor(n/8)) != 0],
otherwise a(n) = a(2*floor(n/8) + 1) + 2 * [a(2*floor(n/8) + 1) != 0].