login
Solution to the spectator-first Tantalizer problem.
1

%I #62 Jan 05 2022 13:56:26

%S 1,2,2,2,2,4,4,6,6,8,8,6,6,8,8,6,6,8,8,6,6,8,8,14,14,16,16,14,14,16,

%T 16,22,22,24,24,22,22,24,24,30,30,32,32,30,30,32,32,22,22,24,24,22,22,

%U 24,24,30,30,32,32,30,30,32,32,22,22,24,24,22,22,24,24

%N Solution to the spectator-first Tantalizer problem.

%H Marc Kouyoumdjian, <a href="/A347325/b347325.txt">Table of n, a(n) for n = 1..10000</a>

%H Wei-Tung Chuang, Hong-Bin Chen and Fu-Yuen Hsiao, <a href="https://doi.org/10.1016/j.disc.2021.112515">General solution to the spectator-first Tantalizer problem</a>, Disc. Math. (2021) Vol. 344, No. 10, 112515. Gives first 100 terms.

%H Yiwei Zhang, <a href="https://leetcode.com/problems/elimination-game/discuss/87128/C-1-line-solution-with-explanation">C 1 line solution with explanation</a>.

%F a(n) = 2 * (floor(n/2) + 1 - a(floor(n/2))) for n > 1. See Zhang's solution. - _Zirui Wang_, Jan 02 2022

%o (Python)

%o def A347325(n):

%o a = [i for i in range(1,n+1)]

%o while len(a) != 1:

%o del a[:len(a)+1:2]

%o a.reverse()

%o return a[-1] # _Marc Kouyoumdjian_, Dec 15 2021

%o (Python)

%o def a(n):

%o return 1 if n <= 1 else 2 * (n // 2 + 1 - a(n // 2))

%o # See Zhang's solution. - _Zirui Wang_, Jan 02 2022

%o (Python)

%o from math import log, log2

%o def A347325(n):

%o return (-2) ** int(log2(n)) // 3 + 1 + (n & int('a' * int(log(n, 16) + 1), 16))

%o # _Zirui Wang_, Jan 03 2022

%o (PARI) a(n)={my(s=1,v=0); while(n>1, n=n\2; s=-2*s; v-=s*(1+n)); v+s} \\ _Andrew Howroyd_, Jan 02 2022

%K nonn

%O 1,2

%A _N. J. A. Sloane_, Sep 13 2021