[Question]
  [
Given \$ i = \sqrt{-1} \$, a base-\$ (i - 1) \$ binary number \$ N \$ with \$ n \$ binary digits from \$ d\_{0} \$ to \$ d\_{n - 1} \$ satisfies the following equation.
$$ N = d\_{n - 1} (i - 1) ^ {n - 1} + d\_{n - 2} (i - 1) ^ {n - 2} + \cdots + d\_{1} (i - 1) + d\_{0} $$
For example, a decimal number \$ 15 \$ is \$ 100011101 \$ in base-\$ (i - 1) \$ since,
$$ (i - 1) ^ {9 - 1} + (i - 1) ^ {5 - 1} + (i - 1) ^ {4 - 1} + (i - 1) ^ {3 - 1} + (i - 1) ^ {1 - 1} $$
$$ = 16 + (-4) + (2 + 2i) + (-2i) + 1 = 15 $$
This is a list of \$ 0 \$ to \$ 9 \$ converted to base-\$ (i - 1) \$.
```
0         0
1         1
2      1100
3      1101
4 111010000
5 111010001
6 111011100
7 111011101
8 111000000
9 111000001
```
Given a decimal integer as input, convert the input to a base-\$ (i - 1) \$ binary number, which is then converted again to decimal as output.
For example,
```
 15 -> 100011101 -> 285
(in)               (out)
```
You may assume that the input is always \$ \ge 0 \$, and the output will fit in the range of \$ [0, 2^{31})\$.
---
### Test cases
```
0 -> 0
1 -> 1
2 -> 12
3 -> 13
4 -> 464
5 -> 465
6 -> 476
7 -> 477
8 -> 448
9 -> 449
2007 -> 29367517
9831 -> 232644061
```
  
[Answer]
# [Python](https://www.python.org), 49 bytes (@xnor)
```
lambda n:3*int(f"{n+a^a:b}",4)&a+a//12
a=2**34//5
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vweI025ilpSVpuhY3DXMSc5NSEhXyrIy1MvNKNNKUqvO0E-MSrZJqlXRMNNUStRP19Q2NuBJtjbS0jE309U2hGt0KisDqNSw1NRWUFUxMLLlgIkYGBuZgQSNLYzNzU0NzuIylhbEhRMbYyMzExMDMEGLaggUQGgA)
## Old [Python](https://www.python.org), 51 bytes
```
lambda n:3*int(f"{n+a^a:b}",4)&a+a//12
a=0xcccccccc
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vweI025ilpSVpuhY3jXMSc5NSEhXyrIy1MvNKNNKUqvO0E-MSrZJqlXRMNNUStRP19Q2NuBJtDSqSoQCq1a2gCKxDw1JTU0FZwcTEkgsmYmRgYA4WNLI0NjM3NTSHy1haGBtCZIyNzExMDMwMIaYtWAChAQ)
### How
In polar coordinates the base is \$b\_k = \sqrt 2^k \times e^{\frac{3ki\pi} 4}\$. From this it is easy to verify
$$
\begin{align}
1 &= b\_0 & 2 &= b\_2+b\_3 & -4 &= b\_4 & -8 &= b\_6+b\_7 \\
16 &= b\_8 & 32 &= b\_{10}+b\_{11} & -64 &= b\_{12} & &\ldots
\end{align}
$$
*Display 1*
Observations:
1. as the size of the base is \$\sqrt 2\$ we need twice the number of 'bits' than in standard binary.
2. Bits 1, 5, 9, ... are never used. This is encoded by the bitmask `0b ... 1101 1101 1101 = 0xdddddddd = a + a//12`
3. Standard bits 2,3,6,7,10,11,... occur with a negative sign. This is encoded by the bitmask `0b ... 1100 1100 1100 = 0xcccccccc = a`.
We can do the transformation in two steps: from standard base S = 1,2,4,8,16,32,... to 'alternating' A = 1,2,-4,-8,16,32,... and then from A to final base C (for 'complex').
Step 1, S->A:
Because of observation 3 if any of the bits of `a` is set in the input *n* (S bits) we need to borrow from the next higher bit. If that bit is also in `a` or was already set in *n* we need to borrow from the next higher bit and so on.
One can check that the right cascade of carries is triggered by simply adding *n* and `a`.
One can also check that afterwards the not in `a` A bits are already correct whereas the in `a` A bits are all wrong. In other words we need to `xor` with `a` and that completes step 1.
Step 2, A->C:
For this we just need to look up the bit pairs from display 1. One way of doing this is to repeat all bits and then mask as explained in observation 2.
[Answer]
# [APL (Dyalog Extended)](https://github.com/abrudz/dyalog-apl-extended), 17 [bytes](https://github.com/abrudz/SBCS)
Full program. Counting up from `¯1` (exclusive) check if the binary representation interpreted as base `¯1J1` matches the input.
```
1+⍣(⎕=¯1J1⊥2⊤⊣)¯1
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT9dNrShJzUtJTfn/qKM97b@h9qPexRqP@qbaHlpv6GX4qGup0aOuJY@6FmsC@SAl/9MUuBQMuECkIZg0ApPGYNIETJqCSTMwaQ4mLcCkJUSXKQA "APL (Dyalog Extended) – Try It Online")
---
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 28 [bytes](https://github.com/abrudz/SBCS)
```
{0=⍵:0⋄(16×∇-⌊⍵÷4)+12⊥2 2⊤⍵}
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///v9rA9lHvViuDR90tGoZmh6c/6mjXfdTTBRQ7vN1EU9vQ6FHXUiMFILkEKFT7P@1R24RHvX2P@qZ6@j/qaj603vhR20QgLzjIGUiGeHgG/9d41LtKJ@3QCk0FAx0ge7Olpo6RgYG5gqWFsSEA "APL (Dyalog Unicode) – Try It Online")
The Python implementation on OEIS can be simplified to
$$
f(n) = \begin{cases}
0 & \text{if } n = 0 \\
16 f(-\lfloor{n \over 4}\rfloor) + [0,1,12,13][n \bmod 4] & \text{otherwise.}
\end{cases}
$$
`12⊥2 2⊤⍵` is a short way of expressing the mod-4 mapping using the base conversion primitives, everything else should map 1-to-1 to the mathematical notation.
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 33 bytes
Implementation of the formula mentioned in my other answer. Borrowed the `3-n>>2` from a comment by [AnttiP](https://codegolf.stackexchange.com/users/84290/anttip).
```
f=n=>n&&1-(n&3)&13^1|f(3-n>>2)<<4
```
[Try it online!](https://tio.run/##BcHdCoMgGADQe5/CixCFT8lsq1h5tyfocmwk/a0RGiYjaD17O@djvmZt/bQEbl3Xn@dQ2UpbQiSnlihGpHrJ30AVt1onrCzT84bQIwYJCShI4QJXyCCHApI4zqDIlXyKwfm7ad8UYbzhSuPW2dXNvZjdSJto30RwdfCTHSkTi@nqYHygKTsw1zjaB7qxo2GInX8 "JavaScript (Node.js) – Try It Online")
The `(n&3)` could be `n%4` in Python, but Javascript handles negative dividends differently.
While one could have come up with the magic formula `1-(n&3)&13^1` by hand, I used Lynn's [pysearch](https://github.com/lynn/pysearch) to find it.
| `(n&3)` | `1-(n&3)` | `1-(n&3)&13` | `1-(n&3)&13^1` |
| --- | --- | --- | --- |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 |
| 2 | -1 | 13 | 12 |
| 3 | -2 | 12 | 13 |
 
[Answer]
# [R](https://www.r-project.org/), ~~54~~ 51 bytes
Or **[R](https://www.r-project.org/)>=4.1, 44 bytes** by replacing the word `function` with a `\`.
*Edit: -3 bytes thanks to [Polichinelle](https://codegolf.stackexchange.com/users/110836/polichinelle).*
```
f=function(n)`if`(n,16*f(-(n%/%4))+n%%4*6-5*n%%2,0)
```
[Try it online!](https://tio.run/##K/r/P802rTQvuSQzP08jTzMhMy1BI0/H0EwrTUNXI09VX9VEU1M7T1XVRMtM11QLyDDSMdD8n6ZhoMmVk1hQkFOpYWhlZKCTpvkfAA "R – Try It Online")
Based on [formula found by @ovs](https://codegolf.stackexchange.com/a/243119/55372).
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 8 bytes
```
Bḅ-ı=ʋ1#
```
[Try it online!](https://tio.run/##y0rNyan8/9/p4Y5W3SMbbU91Gyr/P9z@qGnN//8GOoY6RjrGOiY6pjpmOuY6FjqWAA "Jelly – Try It Online")
Let \$f(n)\$ be the function described in the question. We use the fact that \$f(n) \ge n\$ for al \$n = 0,1,2,...\$ to save a couple of bytes.
## How it works
```
Bḅ-ı=ʋ1# - Main link. Takes n on the left
     ʋ   - Group the last 4 links into a dyad g(k, n):
B        -   Convert k to binary
 ḅ-ı     -   Convert this to base -ı (-1+1j)
    =    -   Does this equal n?
      1# - Find the first k ≥ n, such that g(k,n) is true
```
[Answer]
# JavaScript, 42 bytes
```
f=(x,y=0)=>x|y&&x+y&1|2*f(1-y-x>>1,x-y>>1)
```
[Try it online!](https://tio.run/##DYpBDsIgEAC/svFAWCmmePBS4S9NBbNauw0Ywyb9O5I5zBzmNf/msmTav7bs9Ij5w9s7SmvJ6zqIH9GHeohS1Yhyx/WctLNiawhuqFa6sCXOoAk8jBMQ3D24Ww9jEBbeCq/xsvKzDwZOHQNJE@LU/g "JavaScript (SpiderMonkey) – Try It Online")
`f(x,y)` produces the base-\$(-1-i)\$ representation of \$ x+iy \$ (which is identical to the base-\$(-1+i)\$ representation for real numbers) reinterpreted as binary, for integers \$x,y\$.
`x|y` is zero iff `x` and `y` are both zero; the `&&` short-circuits to produce zero in that case. Otherwise, `x+y&1` gives the ones digit of the base-\$(-1-i)\$ representation of \$ x+iy \$ (since all higher digits contribute an even amount to `x+y`), and the recursive call produces the rest of the digits.
[Answer]
# [Factor](https://factorcode.org/), ~~82~~ 78 bytes
```
:: f ( m -- n ) m [ 0 ] [ 4 / ⌊ neg f 16 * m 4 rem "\0
\r"nth + ] if-zero ;
```
[Try it online!](https://tio.run/##HY09bsJAEEaVFuUQT1QEZLD5xxwA0dCgVCGF5cyChb1r1kuRIC6AOGUu4ozSjD7N996MyfLgfPu@3@42KVUWTpzFWykpXZ6Vzf9qeLVF7r6ERi5Xsbk01F5C@K59YQPrznaXcnSladMUQ4@KKMLypuGDmE@dU0b8Ph9YOSqSzOlrOcVLRfcQv7wefNfq84HChYl@xDvW7U3lhDETJWfMWbBkRTJjHMcLVstJwl1vG5WqrGbY/gE "Factor – Try It Online")
This is a direct implementation of the recursive [formula](https://codegolf.stackexchange.com/a/243119/97916) given by @ovs.
And for posterity, my original answer:
# [Factor](https://factorcode.org/) + `lists.lazy math.unicode`, 85 bytes
```
[ 0 lfrom [ >bin reverse 49 swap indices C{ -1 1 } swap n^v Σ = ] with lfilter car ]
```
[Try it online!](https://tio.run/##JY5PDsFAGMX3TvEuoFEUJWwsxMZGrIRkTL@mE9NpfTOtIE7jPq5UI7N8f/J7LxfSVdwd9tvdZg6trLORFs8HSuGKqBZsiWHp1pCRZHElNqRRMzn3qFkZF4ot/TE2iMYoWWUUaFj0ei8MEGOIEcZIMMEUM6SIE7y7o490zlWJI1YXZcDUkh/FOIW9ixrKZOq/vH6hH3vKO9jm3OL7wRIn3JUrPENp569KwTh1pW9E3Q8 "Factor – Try It Online")
## Explanation
Tries every number starting from 0 until it finds a match, in a brute force way. Slow for the larger inputs, but should theoretically eventually finish.
* `0 lfrom [ ... = ] with lfilter car` Apply `...` to every number >= 0 until it equals the input.
For instance, for input 15 and n=285...
```
                 ! 15 285
>bin             ! 15 "100011101"
reverse          ! 15 "101110001"
49               ! 15 "101110001" 49
swap             ! 15 49 "101110001"
indices          ! 15 V{ 0 2 3 4 8 }            (get indices of the 1s)
C{ -1 1 }        ! 15 V{ 0 2 3 4 8 } C{ -1 1 }  (i-1)
swap             ! 15 C{ -1 1 } V{ 0 2 3 4 8 }
n^v              ! 15 V{ 1 C{ 0 -2 } C{ 2 2 } -4 16 }
Σ                ! 15 15                        (sum)
=                ! t
```
[Answer]
# x86\_64 machine code, 31 bytes (or 27 bytes)
```
\x81\xc7\xcc\xcc\x00\x00\x81\xf7\xcc\xcc\x00\x00\xb8\x55\x55\x55\x55\xc4\xe2
\x43\xf5\xc0\x8d\x04\x40\x25\xdd\xdd\xdd\xdd\xc3
```
[Try it online!](https://tio.run/##bY7haoMwFIV/L09xSSkkoxZbdbW49kWWIZrENbDFoXGkG3t2l@gglu3HgY9zzz338uiF83GlNH8dhITH3gjVbi/nsSwrYzpVD0aWJSG95Ea1muCtkdZgSinwS9VBrfTTM5wQZjbfMcsPTnxWHM/yfvOPX@fMZtmteMqs3GNflyZuzVu@QrgVN0od750nxK14gos/H1/7j7KqlftUaQPkvqHEAYWTf7pAaCVko7SE987ZxNIZGoLXAqIzrAXTeAN2A40bUoR8y1ulNKHwhe4W4fpqZM/0FJ9O9OpTtg1xZyhEsKPFb5zEARfuPmASMA2YBXwIeAiYBzwueuN4kTnmyXSzk2boNMQF@h5/AA)
**assembly**
```
add edi, 0xcccc
xor edi, 0xcccc
mov eax, 0x55555555
pdep eax, edi, eax
lea eax, [rax + rax * 2]
and eax, 0xdddddddd
ret
```
This is a port of [the amazing solution from @loopywalt](https://codegolf.stackexchange.com/a/243137/108859). See his post for a detailed explanation of the algorithm. [`pdep`](https://www.felixcloutier.com/x86/pdep) is an interesting instruction which solves a problem that otherwise needs some sort of loop or a look-up table. It executes in constant time fast on any Intel hardware that supports it, but on AMD chips before Zen3, [it was a slow microcoded instruction with variable latency](https://uops.info/table.html?search=pdep%20(r32%2C%20r32%2C%20r32)&cb_lat=on&cb_tp=on&cb_uops=on&cb_HSW=on&cb_ZEN2=on&cb_ZEN3=on&cb_measurements=on&cb_base=on&cb_bmi=on&cb_others=on).
The sequence of 6 instructions has a blazing [estimated throughput of 2 cycles](https://bit.ly/3JNhfPc).
The first two instructions can be modified to save 4 bytes, but it will run a bit slower.
```
mov ax, 0xcccc
add edi, eax
xor edi, eax
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~33~~ 32 bytes
```
f=n=>n&&f(3-n>>2)*16|6*(n&2)|n&1
```
[Try it online!](https://tio.run/##bZrdzl21EYbPcxVfe4ASSiuP/0c0nPUqEKoQTSoqlFSBIg5679TzPuPVH1UCP6O97NcznvGy9873t29//vbH7z59//effv/h41/e/frr@7cf3n714bPP3r9uv//w1Vf1zec2/zk/f/3hs/rmnx8@s1@/fPXq/cdPL69/ePfTyy8vb1/Klwd/fPvih7/73ZtXLy/fffzw48cf3v3hh49/ff3LFy/vX//y5s2Xr/7z01rKigfB/33mu1k8C8azVx/fff/jn3/@9od/vPvx7auvyxev7PxXz//ti1d99mjGadaMZp2m72g8HpRoTv@6ajRnRN09mjOijhnNGVHnjuaMaHUXtRatV7Ut2pjotCPamOq0Z2Qre6uNsVaK2hhbYsLTNj3tamPsaFNtjB3h6Glj7KhFrelpVRtjW@9qY2wLh08bY4@Lal1Pi9pYF9seXost6KX05ODz8F5cMCIQXdwRhYjetpqU3l67J9FbPpPS89p30uEsSYOtJlv268mBn2Mm0StzJ9ErvSQt@9Vk6NVaIlPigIo3uKD8C3r2K0nV1QmkJhtUvMEB5V9wQfkXRK/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a9XIYv8Wf9wgZTsuuxb8HyGrX0m/7WONa@o0fa2GR8bT8Wrs8ll1r1Mdqz4j@WHcOVUBa61p1P9aNQ2/ytOwZUR/rxqGKSOvOoapI686hN3ta/owoj5VzUCFptWvdtaJOsG4c3IWwbhzch2SpYtK6c5S7VtQN1o1jlBvHKDeOUW4cVFBad45x14o64unNOXelHNEf64nDnzj8ztHuWv27rka9OR91P2vlz1o5c5zzPHMe1rjWmo@1rtX3Y/kzojwWc4y1M46w2rUyjrDGtbJ2w1rXytoN687Ranksu1bmPKwbh26Cad04ms3HunFY3Y9157BeHuvOYVYfqz0j@mNlPriBpXX3oPX9WHcP2q1d7mI5oj5W5rz4rd3it3aL331e/O7z4rd2i9/aLX5rt/itXW5oad193kt/rBtHW/Oxbhzt1i73NVn11q7VW7tW7z63eve52a3dYz1r5c9aZe0av5Cl5dfKtTJ@JwuresYRVntG9Mca@XRnzsNa18q1CsuvlXGEZc@I@lh3jjr7Y41r5VrZ/XfdsPp@LH9GlMey62nuD7v/3hvWfuLYd44y5mM9azWftcr9YdwA07Jr3bXiHoh145h3n9u8@9zm3efnYp85DyvnGH7Xavhdq3H3eVjtGdEf687R2nysda27VtwTsW7O593nNu8@t3n3@Tkje3@sO8c9B8O6c9x9HpY/I8pjMUfhF7q02rVynxd@p5O1s3bDWvdp1m5YntbKOMK6c6xWH@vM8c3//6uIFztnyvN3Ed@/f3kdfwzx8pu3b1/@468avv7lm3j833848ds/ffr08dNv33z5678A "JavaScript (Node.js) – Try It Online")
This is another implementation of the \$n\rightarrow \lfloor{n/4}\rfloor\$ recurrence given in the OEIS. (I saved a byte by changing `-(n>>2)` to `3-n>>2`, as suggested by @AnttiP and others.)
[Answer]
# [Python 3](https://docs.python.org/3/), ~~65~~ ~~45~~ 40 bytes
```
f=lambda n:n and(n&2)*6+n%2+16*f(3-n>>2)
```
[Try it online!](https://tio.run/##PdBRT4MwEMDxdz7FvSjtxpJyLYUtYV9EfUBWtsXZEaiJuuyz491FJfALpPw50vErna7RLsvQXrr310MHcRehiwcVH1Gv/Do@4Lr0q0HZTdzvUS/hcwx9CgdoQZkCSjqRLluA846piNozNeEaZssLhqH3sUaGCmwcQwVWnqECfcNQYbExYsluUbQsDyIrlkeRVFrTNCK3pTEit4YHklZWnchtZb3IbcU/SnJboRFLWUWRW@ucyK2tvM5SmNNMGzF18RjUJUT1tztaZ/0p9G9h4n3Knz@wdn1egNyVNtfZcJ0gFQHOEb7Po5JPFfDf7zKggz8@qKTlYZzOMakhv6U7bPZwm@9w@x3yFNp2frnnevkB "Python 3 – Try It Online")
*Saved a whopping ~~20~~ 25 bytes thanks to [AnttiP](https://codegolf.stackexchange.com/users/84290/anttip)!!!*
[Answer]
# [Husk](https://github.com/barbuz/Husk), ~~16~~ 14 bytes
```
B16mo?I+10εB_4
```
[Try it online!](https://tio.run/##yygtzv6f@6ip8b@ToVluvr2ntqHBua1O8Sb///@PNtAx1DHSMdYx0THVMdMx17HQsdQxMjAw17G0MDaMBQA "Husk – Try It Online")
Converts to base `-4`, replaces digits `0`, `1`, `2`, `3` with `0`, `1`, `12` & `13`, and converts back from base `16`.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 28 bytes
```
ＮθＷθ«Ｆ1220⊞υ＆θＩκ≔±÷θ⁴θ»Ｉ↨⮌υ²
```
[Try it online!](https://tio.run/##HYy7DoJAEEVr@YoJ1WyCCW5MLKxAGxpC/IMVRpiIi@wDCuO3r4vVvcU5px2UaSc1hlDpt3e1f93J4CzOyTrwSBAvfJLdYzKA6UHKPBXQeDugz6Bkt7KlQnc4Z3BR1uFTiKjuCmu511hTrxxhpd2VF@5ow45CZLD1v0ljWDv8e6WyhDdayMT1kZBbKASZ56ewX8Yf "Charcoal – Try It Online") Link is to verbose version of code. Explanation:
```
Ｎθ
```
Input `n`.
```
Ｗθ«
```
Repeat until `n` is zero.
```
Ｆ1220⊞υ＆θＩκ
```
Create four more "bits" in the "base 2" representation of `n` using the digits `0221` bitwise anded with the current value. This results in `0000`, `0001`, `0220` (i.e. `1100`) and `0221` (i.e. `1101`) (although the bits are actually pushed in reverse order so that they accumulate correctly).
```
≔±÷θ⁴θ
```
Integer divide `q` by `4` and negate it. (Sadly this is not the same as integer dividing `q` by `-4`, otherwise I could use negative base conversion.)
```
»Ｉ↨⮌υ²
```
Convert the "bits" from "base 2" and output the result.
[Answer]
# [Pari/GP](http://pari.math.u-bordeaux.fr/), 33 bytes
```
f(n)=if(n,16*f(n\-4)+n%4*6-n%2*5)
```
[Try it online!](https://tio.run/##FYtBCoMwFESvMgiCP52A0Zjqwl6k7cJNS6B8grjp6eN3M/PewJRtz/5bav10Kmu2ZEjO6uWj3LSNLnltBzdJ3Ur5/TuFf6DsWQ/D5pIG11eIZyAGYiQiMRGJuBMzsdje98bLPIa31BM "Pari/GP – Try It Online")
A port of [@pajonk's R answer](https://codegolf.stackexchange.com/a/243145/9288).
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 12 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
4(вεD2@ì}16β
```
Port of [*@DominicVanEssen*'s Husk answer](https://codegolf.stackexchange.com/a/243146/52210), so make sure to upvote him as well!
[Try it online](https://tio.run/##yy9OTMpM/f/fROPCpnNbXYwcDq@pNTQ7t@n/f0NTAA) or [verify all test cases](https://tio.run/##yy9OTMpM/V9Waa@k8KhtkoKSfeV/E40Lm85tdTFyOLym1tDs3Kb/Ov@jDXQMdYx0jHVMdEx1zHTMdSx0LHUMTXWMDAzMdSwtjA1jAQ).
**Explanation:**
```
4(в      # Convert the (implicit) base-10 input-integer to base-(-4) as list
   ε     # Map over each integer in the list
    D    #  Duplicate it
     2@  #  Check if it's >= 2
       ì #  Prepend that 0/1 to the integer
   }16β  # After the map: convert the list from base-16 to a base-10 integer
         # (which is output implicitly as result)
```
Two equal-bytes alternatives for `εD2@ì}` could be `D2@T*+` or `D2@søJ`, but I haven't been able to find anything shorter for this.
[Answer]
## Python, 48 bytes
```
f=lambda n:16*f(-(n//4))+6*(n&2)+n%2 if n else 0
```
This is a recursive function that takes advantage of the fact that because (i-1)^4 = -4, then every 4 bits of the output corresponds to a base -4 number.
`f(-(n//4))` makes the recursive call for the base -4 representation of `n` *except* the last digit. Unfortunately, the inner parentheses are necessary. Multiplying by 16 shifts left 4 binary digits to make room for the last digit.
`6*(n&2)+n%2` is a golfed way to encode the last base -4 digit:
* 00 → 0000
* 01 → 0001
* 10 → 1100
* 11 → 1101
The last bit of the input (`n%2` or `n&1`) corresponds directly to the last digit of the output, while the first bit of the input (`n&2`), corresponds to either 000 (decimal 0) or 110 (decimal 6). Unfortunately, the parentheses in `n&2` are necessary because of operator precedence.
`if n else 0` handles the base case of the recursion.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), 9 bytes
```
λb°‹β?=;ṅ
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCLOu2LCsOKAuc6yPz074bmFIiwiIiwiMyJd)
Port of Jelly.
]