5 added 1338 characters in body
source | link

Python 2, 59 51 49 bytes

f=lambda n,k=2:2/n%-3*(1-k)or f(n+~(k&-k)%-3,k+1)

Try it online!

Background

Every positive n integer can be expressed uniquely as n = 2o(n)c(n), where c(n) is odd.

Let ⟨ann>0 be the sequence from the challenge spec.

We claim that, for all positive integers n, o(a2n-1) is even. Since o(a2n) = o(2a2n-1) = o(a2n-1) + 1, this is equivalent to claiming that o(a2n) is always odd.

Assume the claim is false and let 2m-1 be the first odd index of the sequence such that o(a2m-1) is odd. Note that this makes 2m be the first even index of the sequence such that o(a2m-1) is even.

o(a2m-1) is odd and 0 is even, so a2m-1 is divisible by 2. By definition, a2m-1 is the smallest positive integer not yet appearing in the sequence, meaning that a2m-1/2 must have appeared before. Let k be the (first) index of a2m-1/2 in a.

Since o(ak) = o(a2m-1/2) = o(a2m-1) - 1 is even, the minimality of n implies that k is odd. In turn, this means that ak+1 = 2ak = a2m-1, contradicting the definition of a2m-1.

How it works

yet to come

Python 2, 59 51 49 bytes

f=lambda n,k=2:2/n%-3*(1-k)or f(n+~(k&-k)%-3,k+1)

Try it online!

Python 2, 59 51 49 bytes

f=lambda n,k=2:2/n%-3*(1-k)or f(n+~(k&-k)%-3,k+1)

Try it online!

Background

Every positive n integer can be expressed uniquely as n = 2o(n)c(n), where c(n) is odd.

Let ⟨ann>0 be the sequence from the challenge spec.

We claim that, for all positive integers n, o(a2n-1) is even. Since o(a2n) = o(2a2n-1) = o(a2n-1) + 1, this is equivalent to claiming that o(a2n) is always odd.

Assume the claim is false and let 2m-1 be the first odd index of the sequence such that o(a2m-1) is odd. Note that this makes 2m be the first even index of the sequence such that o(a2m-1) is even.

o(a2m-1) is odd and 0 is even, so a2m-1 is divisible by 2. By definition, a2m-1 is the smallest positive integer not yet appearing in the sequence, meaning that a2m-1/2 must have appeared before. Let k be the (first) index of a2m-1/2 in a.

Since o(ak) = o(a2m-1/2) = o(a2m-1) - 1 is even, the minimality of n implies that k is odd. In turn, this means that ak+1 = 2ak = a2m-1, contradicting the definition of a2m-1.

How it works

yet to come

4 deleted 25 characters in body
source | link

Python 2, 59 51 49 bytes

f=lambda n,k=2:n>1and2/n%-3*(1-k)or f(n+~(k&-k)%-3,k+1)or~-k<<n

Uses 0-based indexing.

Try it online!Try it online!

Python 2, 59 51 49 bytes

f=lambda n,k=2:n>1and f(n+~(k&-k)%-3,k+1)or~-k<<n

Uses 0-based indexing.

Try it online!

Python 2, 59 51 49 bytes

f=lambda n,k=2:2/n%-3*(1-k)or f(n+~(k&-k)%-3,k+1)

Try it online!

3 added 31 characters in body
source | link

Python 2, 59 5151 49 bytes

f=lambda n,k=1k=2:n>0andn>1and f(n--~n+~(k&-k)%3%-3,k+1)or~-k<<-~nk<<n

Try it online! Uses 0-based indexing.

Try it online!

Python 2, 59 51 bytes

f=lambda n,k=1:n>0and f(n--~(k&-k)%3,k+1)or~-k<<-~n

Try it online!

Python 2, 59 51 49 bytes

f=lambda n,k=2:n>1and f(n+~(k&-k)%-3,k+1)or~-k<<n

Uses 0-based indexing.

Try it online!

2 deleted 4 characters in body
source | link
1
source | link