##Python 2, 71 bytes
Python 2, 71 bytes
def a(n,x=0,y=1,z=2,w=1,p=0):
if~n:print[x,z][p];a(n-1,y,x+y,w,z+w,~p)
This definitely seems too long. However, I was pleased that I got to use the bitwise not
operator...twice. Once as kind of a parity flip back and forth, and once to terminate the recursion when n
reaches -1
.
The variable p
will always be either 0
or -1
, so it will alternate between entries 0
or -1
of the list. (Choosing entry -1
of a Python list means choosing the last element.)