Haskell, 69 68 bytes
g x=any(elem x)$scanr(\_->concat.mapM(\y->[y++y,y++map(0-)y]))[[1]]x
Usage example: g [-1,1]
-> False
.
Even more inefficient than @flawr's answer@flawr's answer. It takes too much time and memory for 4 element lists. To see that the list of OVSF codes (with a lot of duplicates) is actually created, try:
take 10 $ c $ scanr(\_->concat.mapM(\y->[y++y,y++map(0-)y]))[[1]] [1..4]
which returns
[[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1],
[1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1],
[1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1],
[1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1],
[1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1],
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
[1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1]]
i.e. the list starts with all 16 element lists (4 times concatenated, because of [1..4]
), continues with all 8 element lists and so on until it ends with [1]
.
Edit: @xnor saved a byte. Thanks!