# Is it a Cyclops number? "Nobody" knows!

## Python 2, 30 bytes

lambda n:(2*n^2*n+3)**2==8*n+9


Try it online!

Note that 2*n^2*n+3 is the bitwise xor of 2*n and 2*n+3, because that's Python's operator precedence.

## x86 Machine Code, 17 bytes

8D 47 01 31 F8 89 C2 F7 D2 0F AF C2 8D 44 78 02 C3


The above bytes define a function that accepts a 32-bit integer input value (in the EDI register for this example, following a common System V calling convention, but you could actually pick pretty much any input register you wanted without affecting the size of the resulting code), and returns a result (in the EAX register) indicating whether the input value is a Cyclops number.

The input is assumed to be an unsigned integer, since the challenge rules state that we can ignore negative values.

The decision logic is borrowed from Neil's answer: since a Cyclops number has the form $$\ n = (2 ^ k + 1) (2 ^ { k - 1 } - 1) \$$, we can use a series of bit-twiddling operations to check the input.

Note: The return value is truthy/falsy, but the semantics are reversed, such that the function will return falsy for a Cyclops number. I claim this is legal because machine code doesn't have "specifications for truthy/falsy", which is the requirement in the question. (See below for an alternative version if you think this is cheating.)

In assembly language mnemonics, this is:

; EDI = input value
; EAX = output value (0 == Cyclops number)
8D 47 01           lea    eax, [edi + 1]          ; \ EAX = ((EDI + 1) ^ EDI)
31 F8              xor    eax, edi                ; /
89 C2              mov    edx, eax                ; \ EDX = ~EAX
F7 D2              not    edx                     ; /
0F AF C2           imul   eax, edx                ; EAX *= EDX
8D 44 78 02        lea    eax, [eax + edi*2 + 2]  ; EAX  = (EAX + (EDI * 2) + 2)
C3                 ret                            ; return, with EAX == 0 for Cyclops number


Try it online!

As promised, if you think it's cheating to invert the semantics of truthy/falsy even in machine code where there are no real standards or conventions, then add three more bytes, for a total of 21 bytes:

; EDI = input value
; AL  = output value (1 == Cyclops number)
8D 47 01           lea    eax, [edi + 1]          ; \ EAX = ((EDI + 1) ^ EDI)
31 F8              xor    eax, edi                ; /
89 C2              mov    edx, eax                ; \ EDX = ~EAX
F7 D2              not    edx                     ; /
0F AF C2           imul   eax, edx                ; EAX *= EDX
8D 44 78 01        lea    eax, [eax + edi*2 + 1]  ; EAX  = (EAX + (EDI * 2) + 1)
40                 inc    eax                     ; EAX += 1
0F 94 C0           setz   al                      ; AL = ((EAX == 0) ? 1 : 0)
C3                 ret                            ; return, with AL == 1 for Cyclops number


The first half of this code is the same as the original (down through the imul instruction). The lea is almost the same, but instead of adding a constant 2, it only adds a constant 1. That's because the following inc instruction increments the value in the EAX register by 1 in order to set the flags. If the "zero" flag is set, the setz instruction will set AL to 1; otherwise, AL will be set to 0. This is the standard way that a C compiler will generate machine code to return a bool.

Changing the constant added in the lea instruction obviously doesn't change the code size, and the inc instruction is very small (only 1 byte), but the setz instruction is a rather whopping 3 bytes. Unfortunately, I can't think of any shorter way of writing it.

## Japt, 8 bytes

1¥¢q0 äè


Run it online

### Explanation:

1¥¢q0 äè
119
¢          // Convert the input into a binary string        "1110111"
q0        // Split the string on "0"                       ["111","111"]
ä      // Reduce each item by:                            a     b
è     //   Seeing how many times a is found in b       [1]
1¥          // == 1; See if the result equals 1              True


The idea is to split the binary string at 0, which would yield two items if there is only one 0. Then we see if the first item matches the second to ensure it is palindromic. If the binary string contains multiple 0s, then the reduce would return a multi-item array and that would fail the ==1 condition. If the binary string does contain one 0, but is not palindromic, äè will return 0 because b contains 0 matches of a.