text:
The (Easy) Road to Code
Input:

An integer \$n\$, which is guaranteed to be \$\ge3\$.
An integer \$d\$, which is one of \$[-1,0,1]\$.

Output:
A road of size \$n\$, which will be in a north-west direction if \$d=-1\$; a north direction if \$d=0\$; or a north-east direction if \$d=1\$. The road will always be three spaces wide (or five in general if we'd include the outer borders). In addition, there will be a road separator line on the bottom section, and after that alternating while going upwards.
Some examples:
Input: \$n=7, d=1\$
Output:
      / / /
     /   /
    / / /
   /   /
  / / /
 /   /
/ / /

Input: \$n=4, d=-1\$
Output:
\   \
 \ \ \
  \   \
   \ \ \

Challenge rules:

Any amount of leading/trailing spaces and/or newlines are acceptable, as long as it prints the required road somewhere on the screen.
Instead of the options \$[-1,0,1]\$ you are also allowed to use the options \$[0,1,2]\$ or \$[1,2,3]\$ instead. Also, you can choose which of the three options map to which of the three directions. (Make sure to mention which options you've used if it differs from the \$[-1,0,1]\$ for [north-west, north, north-east] respectively that is used in this challenge description!)
Any reasonable output format is acceptable. The most common is of course to print it to STDOUT, but returning it as a string or 2D character list is fine as well.

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer with default I/O rules, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code (i.e. TIO).
Also, adding an explanation for your answer is highly recommended.

Test cases:
The two examples above, and:
Input: \$n=10, d=0\$
Output:
|   |
| | |
|   |
| | |
|   |
| | |
|   |
| | |
|   |
| | |

Alternative title: "Mad Max Code Warrior"

Isn't the first example incorrect? It has a middle strip on every odd line instead of every even line

@moonheart08 No. The bottom one will always have a road separator line, whether the input is odd or even. After that it's alternating while going upwards. I've modified the text a bit to hopefully make it clearer.

Oh, so i'm wrong. Alright. Thanks for clarifying.

Canvas, 23 22 bytes
B}⁴H‟ｍ↶⁷？／|∙/╋］＼|∙\╋］｝

Try it here!
Uses the direction inputs 0, 1 and 2.
Explanation:
...‟    push "--¶¶- ¶¶--"
    m   mold the horizontal length to the 1st input - a horizontal road
     ↶  rotate counter-clockwise - so the separator is on the bottom
        also replaces the dashes with bars

⁷?     ]     ]}  switch over the 2nd input:
                 default case (input 2):
  /                pad with spaces to a "/" diagonal
   |∙/╋            replace "|" with "/"
                 case 0:
        \          pad with spaces to a "\" diagonal
         |∙\╋      replace "|" with ""

case 1 is empty, but because of a bug, the trailing "}" is still required

@KevinCruijssen added.

Python 2, 79 78 73 72 bytes
n,d=input()
c='|\/'[d]
i=n
while i:print' '*(n-i*d)+c,i%2*c or' ',c;i-=1

Try it online!
Takes [1,0,-1] for [north-west, north, north-east]
-1 byte, thanks to Neil

Jeez, what I wouldn’t give for Python-like slicing in Kotlin

i%2*c or' ' saves a byte.

Python 2, 66 bytes
n,d=input()
s=' '+'|\/'[d]
for c in(s*n)[n:]:print' '*n+s,c+s;n+=d

Try it online!
Uses d=-1 for NE, d=0 for N, and d=1 for NW. Takes advantage of leading spaces being allowed. The rule that the bottom segment of the road have a separator made it tricky to get the parity right; it's achieved by the slicing (s*n)[n:] taking the second half of the 2n alternations between space and a the road character.

1. Python 3.5, 122 120 bytes
Script takes two params: n, d.
d: 0, 1, 2 -> \ | /
tio.run
import sys;(n,d)=[*map(int,sys.argv[1:3])];c="\\|/"[d]
for i in range(n):j=n+~i;print(" "*(i,0,j)[d],c,c*(j%2<1)or" ",c)

output:
$ ./script.py 6 2
      /   /
     / / /
    /   /
   / / /
  /   /
 / / /
$ ./script.py 6 1
 |   |
 | | |
 |   |
 | | |
 |   |
 | | |
$ ./script.py 6 0
 \   \
  \ \ \
   \   \
    \ \ \
     \   \
      \ \ \

Explanation
# parse input params
(n,d)=[*map(int,sys.argv[1:3])]

# select char for "road"
c="\\|/"[d]

# loop n-times
for i in range(n):

    # complement (how many lines to end)
    j=n+~i

    # print
    #   space i or 0 or j times
    #   road, center of road if j is even else space, road
    print(" "*(i,0,j)[d], c, c*(j%2<1) or " ", c)

edit: -2 bytes thanks to Kevin Cruijssen

Nice answer! :) Two small things to golf: n-1-i can be n+~i (relevant tip) and j%2==0 can be j%2<1. If you haven't seen them yet, Tips for golfing in Python and Tips for golfing in  might both be interesting to read through.

Thank you :) I have'nt seen this n+~i yet, but looks helpful. Also thanks for code highlight.

You're welcome! Enjoy your stay and golfing many answers. :) Oh, and have a nice weekend.

j%2*" "or c saves another couple of bytes.

PowerShell, 88 82 80 74 71 bytes
-8 bytes thanks to Mazzy
-6 bytes thanks to AdmBorkBork and Mazzy
-3 bytes thanks to AdmBorkBork
param($n,$d)$n..1|%{' '*($_,($n-$_))[$d]+($y='/\|'[$d])," $y"[$_%2],$y}

Try it online!
Uses [0,1,2] for NW, NE, N. Uses d as a list index twice to first get the spacing method (Drops off the list when using 2 which returns 0) and then which character to use when drawing the lines. Appends a list to the string of spaces (which innately has spaces between the members when appended as such) which builds the road. Also swaps between an open lane or a dash based on modulo math.

80 bytes if uses [0,1,2] for [NW,NE,N]

@mazzy Smart. I completely forgot about intentionally falling off a list.

Awesome idea with array.toString from AdmBorkBork! Thanks. 74 bytes

71 bytes by indexing the middle part into a string rather than an array.

Charcoal, 33 29 23 bytes
↷ＮＮη⊘⊕ηＵＥ¹¦¹Ｆ⟦²±²⟧«Ｊι⁰η

Try it online! Link is to verbose version of code. Now that all of the underlying Charcoal bugs seem to be fixed I can advertise the optimal code. Explanation:
↶Ｎ

Rotate the cursor direction anticlockwise according to the first input, so that 1 becomes north east, 2 north and 3 north west.
Ｎη

Input the length of the road.
⊘⊕ηＵＥ¹¦¹

Print half the length of the road and then stretch it giving the road separator.
Ｆ⟦²±²⟧«Ｊι⁰η

Print the sides of the road.
@KevinCruijssen subsequently submitted a harder version of this question which was since deleted but users with enough rep can see it here: The (Hard) Road to Code The stretching trick I used in this answer isn't applicable to that question, so instead I wrote the following 47 45-byte program:
Ｆ³«Ｊ×ι⊘⊕θ⁰≔…⟦¹ ⟧⊕﹪ι²ιＦη«↶§κ⁰Ｆ⊖§κ¹§ιⅉＰ§ιⅉ↑↷§κ⁰

Try it online! Link is to verbose version of code. Explanation:
Ｆ³«

Loop over the sides and separator.
Ｊ×ι⊘⊕θ⁰

Jump to the start of the side.
≔…⟦¹ ⟧⊕﹪ι²ι

Make an array containing a 1 and a space, but remove the space again if we're drawing the sides rather than the separator.
Ｆη«

Loop over each road section.
↶§κ⁰

Rotate the cursor direction accordingly.
Ｆ⊖§κ¹

Loop over one less than the length of the road section...
§ιⅉ

... and print alternating elements of the array. The alternation is achieved by cyclically indexing into the array with the Y-coordinate of the cursor.
Ｐ§ιⅉ

Print the last row of this road section, but without moving the cursor...
↑

... so that the cursor can be moved up ready for the next section instead.
↷§κ⁰

Rotate the cursor direction back ready for the next section.

C (gcc), 100 90 bytes
f(a,b,c,d){for(c=a,d="\\|/"[b+1];c--;)printf("%*c %c %c\n",b>0?c+1:b?a-c:0,d,c%2?32:d,d);}

Try it online!

Well written version

88 bytes

Kotlin, 96 92 bytes
{n,d->val c="\\|/"[d];(0..n-1).map{println(" ".repeat(n-it*(d-1))+ "$c ${" $c"[it%2]} $c")}}

Accepts [0, 1, 2] instead of [-1, 0, 1]
It works similarly to solutions in other languages, but unfortunately Kotlin doesn’t really shine in this one.
val c=“\\|/“; retrieves the char to use in road building by taking advantage of the fact that Kotlin treats Strings like an Array of chars (as it should, looking at you Java)
Try it online!

Hi, welcome to PPCG! There is a minor issue in your output. The altering lines in the center of the road should start with a line at the bottom for even inputs, instead of at the top. You can compare your output for 4 with my example of 4 to see the difference I mean. I don't know Kotlin that well, but I think you can solve it (and golf 4 bytes at the same time) by changing [(it+1)%2] to [it%2]. :) Apart from that it's a nice answer, so +1 from me.

Awesome, thanks so much for the welcome & help! I’ll change it

TSQL code, 171 117 bytes
I realized this could be written much shorter as code.
DECLARE @n INT=7,@d INT=0

,@ INT=0a:PRINT
space(@n-@*@d)+stuff(replicate(substring('\|/',@d+2,1)+' ',3),3,@%2,space(@%2))SET
@+=1IF @n>@ GOTO a

TSQL query, 137 bytes
USE master
DECLARE @n INT=6,@ INT=-1

SELECT space(@n-y*@)+z+iif(y%2=1,z,'  ')+z
FROM(SELECT top(@n)row_number()over(order
by @)y,' '+substring('\|/',@+2,1)z FROM spt_values)x

USE master is not necessary, if your database is master already. Some users however have a different default database.
Script when trying it out is slightly different. I had to replace space ascii-32 with ascii-160, the spaces were not shown.
Try it out
Made some tweaks and realized that I could replace

order by 1/0

with

order by @

How come order by 1/0 doesn't cause a divide by zero error?

because 1/0 is not being calculated. where exists(select 1/0) will have the same effect

Moved my question to StackOverflow

JavaScript (ES8),  90 87  85 bytes
Takes input as (direction)(length). Expects \$0\$ for North-West, \$1\$ for North or \$2\$ for North-East.
d=>g=(n,w=n)=>n?(c='/|\\'[d]).padStart([n--,,w-n][d])+` ${n&1?' ':c} ${c}
`+g(n,w):''

Try it online!

JavaScript (ES6), 90 bytes
This one draws the output character by character with a little more maths instead of the .padStart() method.
Takes input as (direction)(length). Expects \$1\$ for North-West, \$2\$ for North or \$3\$ for North-East.
d=>n=>(g=x=>y?` /|\\
`[x+5?17+y%2*4>>--x+5-[,n+1-y,n,y][d]&1&&d:(x=n,y--,4)]+g(x):'')(y=n)

Try it online!

Jelly,  31  30 bytes
⁶ẋẋƤḂ};€ị“\/|”ẋ3KƊ}Ṛ⁹¡⁶-2¦€ÐeṚ

A dyadic Link accepting the length on the left and the negated-direction* on the right which yields a 2d array of characters.
* [north-west, north, north-east]=[1, 0, -1]
Try it online! (footer calls the Link, joins with newline characters and prints the result)
How?
⁶ẋẋƤḂ};€ị“\/|”ẋ3KƊ}Ṛ⁹¡⁶-2¦€ÐeṚ - Link: integer, L; integer, D
⁶                              - space character
 ẋ                             - repeat L times
     }                         - using the right argument (D):
    Ḃ                          -   mod 2 (0 if D = 0, 1 otherwise ...A would work too)
   Ƥ                           - for each prefix (of the list of spaces):
  ẋ                            -   repeat (D mod 2 times)
                  }            - using the right argument (D):
                 Ɗ             -   last three links as a monad:
        ị“\/|”                 -     index into "\/|" (1-indexed & modular)
              ẋ3               -     repeat three times - e.g. "\\\"
                K              -     join with spaces          "\ \ \"
      ;€                       - concatenate €ach (altered prefix with that list)
                     ¡         - repeat action...
                    ⁹          - ...number of times: right argument (-1 repeats 0 times)
                   Ṛ           - ...action: reverse (i.e. reverse if north-west)
                           Ðe  - for even indexes:
                         ¦€    -   sparse application for €ach...
                       -2      -   ...to indices: [-2] (the middle of the road)
                      ⁶        -   ...action: a space character
                             Ṛ - reverse

Python 2, 127 bytes
n,d=input()
c='|/\\'[d]
for i in range(n):t=0if d==0else(i if d<0else n-i);print(' '*t+'{} {} {}'.format(c,' 'if i%2==0else c,c))

Try it online!
First two lines taken from @TFeld.

Hi there, welcome to PPCG! I'm afraid submissions will have to be either a function taking parameters, or a full program taking arguments or input from STDIN. Snippets like you're using right now aren't allowed I'm afraid. You could add a leading D,N=input() (and use Python 2 instead of 3) to fix this. Or you could change it to a lambda function taking these two parameters.

Nice solution. Got it to 122 using " ".join(..) rather ran .format

i%2*c or' ' saves a few more bytes, although I did notice that the separator is wrong for odd length roads.

J, 64 bytes
' \|/'{~(_2&|*[:i.[*1 _1{~3=])|."_1((5+[){."1(5,~[)|.@$]*#:@689)

Try it online!

1 North-West
2 North
3 North-East

Will try to golf it later

Python 2, 93 bytes
n,d=input();p=''
while n:g='|/\\'[d];n-=1;print['',' '*n,p][d]+g+' %s '%(g,' ')[n%2]+g;p+=' '

Try it online!

Changing +' %s '+ to ,'%s', saves 2 bytes

@TFeld In that case you might as well remove the '%s'% completely.

C# (Visual C# Interactive Compiler), 129 107 103 93 bytes
a=>b=>{for(char i=a,W="/|\\"[b+1];i>0;)Write("{0,"+(a-i*b+5)+"} {1} {0}\n",W,--i%2<1?W:' ');}

-1 for north-east, 1 for north-west, 0 for north
Try it online!

Vyxal, 91 bytes
£:0=[¥(n₂[`| | |`|`|   |`],)|1=[¥(ðn*n₂[`\ \ \\`|`\   \\`]+,)|¥(ð¥‹n-*n₂[`/ / /`|`/   /`]+,

Try it Online!
A little better.

91 bytes

@AaronMiller Thanks!

Wait, no. 90 bytes

Red, 157 bytes
func[s d][p: pick"\|/"d set[a b]reduce pick[[4 1]0[5 + s -1]]d
repeat n s[print pad/left form reduce pick[[p" "p][p p p]]odd?(n + pick[1 0]odd? s)a: a + b]]

Try it online!

1 North-West
2 North
3 North-East

Japt, 53 bytes
W="|/\\"gV;Æ"{W} {YÉ %2?W:' } {W}"ùVÄ?V?Y+5:5:U-Y+4Ãw

Try it Online!

Stax, 23 bytes
ù╒←∩♂2Ωⁿ¡├∩22♀Ç○=÷â╧δÖ↑

Run and debug it
Input is two integers separated by a space.
The first is d.  -1 specifies north-east.  0 for north.  1 for north-west.
The second parameter is n.
These two values will get implicitly parsed from input and placed on the input stack with n on top.
Additionally d will be accessible from the stax's x register since it's the first implicitly parsed value.
For example, input "1 7"
            Main stack      Explanation
            ----------      -----------
;           [7]             peek from input stack
m                           map over integers [1..n] using the rest of the program
                            output each produced value implicitly
  ;         [1 7]           peek from input stack
  +         [8]             add
  .*"       [8 [42 34]]     2 character string literal with codepoints 42 and 34
  @         [42]            get the element at the specified modular index (8)
  0         [42 0]          literal zero
  "|\/"x@   [42 0 92]       get codepoint from string literal at input d (from x register)
  \         [42 [0 92]]     make pair
  :B        ['\ \ \ ']      encode in custom base; it's binary with custom codepoints
  _x*       ['\ \ \ ' 1]    (loop variable) * (input d)
  ;^        ['\ \ \ ' 1 8]  peek from input stack and increment
  %         ['\ \ \ ' 1]    modulus
  6+        ['\ \ \ ' 7]    add 6
  )         [' \ \ \ ']     left-pad to length

Run this one

@KevinCruijssen: Not at all.

Swift 4.2, 112 108 bytes
-4 bytes thanks to Sriotchilism O'Zaic
let c=["\\","|","/"][d];(0..<n).map{print((0..<n-$0*(d-1)).map{_ in" "}.joined()+c+" \($0%2==0 ?c:" ") "+c)}

[0,1,2] instead of [-1,0,1].
Try it online!
Explanation
let c=["\\","|","/"][d]

Determines the street sign to use. (I bet this can be shortened somehow)
(0..<n).map{

Iterates over the length of the street.
(0..<n-$0*(d-1)).map{_ in" "}.joined()

Adds the spaces in front of the street.
\($0%2==0 ?c:" ")"

Adds the middle sign to every other line.
My very first one ☝, I'm happy about any optimization advices. Learned mostly from that thread: Tips for golfing in Swift.

Welcome to the site!  It seems like you forgot to remove the space in between in and " " in your code even though you have removed it in your examples.

I don't know swift but it looks like for your interpolations on the ends of the strings (\(c) in both cases). You would save bytes by just concatenating the c to the string. Try it online!

Thanks, you are right! saved us 3 bytes

Japt -R, 40 bytes
Æ=Vg"|\\/";²i1S+iX%2?S:U)iSp[TZÊ-YY]gVÃw

Try it online!
Explanation:
Æ=Vg"|\\/";²i1S+iX%2?S:U)iSp[TZÊ-YY]gVÃw
                                            // U = road size
                                            // V = direction
Æ                                     Ã     // Loop X through [0...U]
 =        ;                                 //   Set U to:
    "|\\/"                                  //       "|\/"
  Vg                                        //            [V]
           ²                                //  Double U
            i1          )                   //  Insert at index 1:
              S+                            //    " " +
                 X%2?S:U                    //         X%2?" ":U
                i                           //                  + " "
                         i                  //  Insert at index 0:
                          Sp                //    " " repeated this many times:
                            [TZÊ-YY]        //      [0,U.length - X,X]
                                    gV      //                        [V]
                                        w   // Reverse output

There seems to be a minor mistake in the output. Currently the road separator for even inputs starts at the top instead of the bottom. Everything else looks ok, so I hope it's not too hard of a fix.

@KevinCruijssen Ah, thanks for catching that. Before I update my answer, can you confirm that this solution is okay?

Yep, that looks completely correct. :)

@KevinCruijssen Added an explanation since I know you like those :P

Thanks, appreciated. :) I indeed always like to have explanation for golfing languages. I sometimes already have trouble understanding the JavaScript answers, let alone the golfed language of JS. ;)

Perl 6, 66 bytes
->\n,\d{{(' 'x--$ *d%-+^n~(' ',<\ | />[d+1])[1,(n+$++)%2,1])xx n}}

Try it online!
Returns a list of lines.
Explanation
->\n,\d{                                                         }  # Block taking n, d
        {                                                       }   # Reset $ variables
         (                                                 )xx n    # Repeat n times
          ' 'x  # Space times
              --$ *d  # (-1,-2,-3,...) if d=1
                      # (0,0,0,...) if d=0
                      # (1,2,3,...) if d=-1
                    %-+^n  # modulo -~n = n+1
                         ~  # Concat
                          (' ',<\ | />[d+1])  # Space or line
                                            [1,(n+$++)%2,1]  # Alternate middle char

Ruby, 90 bytes
n,a=*$*.map{|i|-i.to_i}
c='|\/'[a]
n.upto(-1){|i|puts' '*(i*a-n)+c+' '+[' ',c][i%2]+' '+c}

Try it online!
UPDATE: Thank you, Kevin, for pointing out that my original submission was missing spaces between the road edges and markers (i.e., 3-width roads instead of 5-width.) That said, there might be a shorter fix for that than c+' '+...+' '+c.
Directional information: -1, 0, 1 maps to { north-west, north, north-east }
Arguments: this reads command-line arguments such as 4 -1 (a four row road, slanted to the north-west).
Additional note: This was tested locally with Ruby v2.6.1, and it appears that Try It Online uses Ruby v2.5.3. I have no reason to think it would not work with all other Ruby versions.

Hi there, welcome to PPCG! The directions and altering roads are correct in your output, so well done. There is just one minor error in the current output: the road should be three spaces wide instead of 1. Currently your road is ||| or |<sp>|, but it should be |<sp>|<sp>| or |<sp><sp><sp>| (where <sp> is a space). I don't know Ruby, but It seems you can solve it by changing c+[' ',c][i%2]+c to c+' '+[' ',c][i%2]+' '+c. :)

Ah good catch! Thanks for pointing that out, @KevinCruijssen.

Java (JDK), 116 bytes
d->n->{for(int c="\\|/".charAt(d),i=n;i-->0;)System.out.printf("%"+(d<1?n-i:d>1?i+1:1)+"c%2c %c%n",c,i%2<1?c:32,c);}

Try it online!
Takes d as one of 0, 1 or 2.

108 bytes Takes input -1 for northwest, 1 for north-east, and 0 for north.

perl -M5.010 -Mfeature=signatures, 97 bytes
sub f($n,$d){$x=qw[| / \\][$d];say" "x($d<1?$_*-$d:$n-$_),$x,$",($n-$_)%2?$":$x,$",$x for 1..$n;}


text:
Is it a Cyclops number? "Nobody" knows!
Task:
Given an integer input, figure out whether or not it is a Cyclops Number.
What is a Cyclops number, you may ask?  Well, it's a number whose binary representation only has one 0 in the center!
Test Cases:
Input | Output | Binary  | Explanation
--------------------------------------
0     | truthy | 0       | only one zero at "center"
1     | falsy  | 1       | contains no zeroes
5     | truthy | 101     | only one zero at center
9     | falsy  | 1001    | contains two zeroes (even though both are at the center)
10    | falsy  | 1010    | contains two zeroes
27    | truthy | 11011   | only one zero at center
85    | falsy  | 1010101 | contains three zeroes
101   | falsy  | 1100101 | contains three zeroes
111   | falsy  | 1101111 | only one zero, not at center
119   | truthy | 1110111 | only one zero at center

Input:

An integer or equivalent types. (int, long, decimal, etc.)
Assume that if evaluating the input results in an integer overflow or other undesirable problems, then that input doesn't have to be evaluated.

Output:

Truthy or falsy.
Truthy/falsy output must meet the used language's specifications for truthy/falsy.  (e.g. C has 0 as false, non-zero as true)

Challenge Rules:

Input that is less than 0 is assumed to be falsy and thus does not have to be evaluated.
If the length of the binary representation of the number is even, then the number cannot be a Cyclops number.

General Rules:

This is code-golf, so the shortest answers in bytes wins!.
Default loopholes are forbidden.
Standard rules apply for your answer with default I/O rules.

This is my first Programming Puzzles & Code Golf challenge, so any feedback on how I should improve would be much appreciated!

Note: This is A129868

+1 for the 2800 year late pop culture reference in the title

what is the maximum number that is be tested?

@Serverfrog since I did not specify a limit, assume that any positive integer can be tested.

Is binary input allowed?

Suggest case 11(1011)

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.

Took my pre-caffeinated brain a couple of seconds to see what was happening here! Nicely done. r¶ should also work.

I don't know Japt, but if I understand correctly it does the following: ¤ = convert to binary; q0 = split on 0s; äè I'm not entirely sure..; and the flag -N converts lists to NaN, but leaves 0 and 1 the same. For the äè part I can see that 119 is [111,111] after the split, which äè changes to 1; and 85 is [1,1,1,1] after the split, which äè changes to [1,1,1]. Could you explain how .ä("è") works?

@KevinCruijssen I added an explanation. I hope that helps.

@KevinCruijssen, no better time to learn Japt ;) As well as that, I'm also working on a new interpreter for Japt, with a load of new features.

Is NaN falsey in Japt? (i.e. if you perform an if-else with that as the condition does the if get executed? "Truthy/falsy output must meet the used language's specifications for truthy/falsy") Also 2 yields 2 which I doubt is falsey (but might be if Japt is like 05AB1E).

@JonathanAllan assuming that Japt is like JavaScript (which i'm assuming is true since it's just transpired from JS), NaN would be considered falsy.

@Tau ...but not 2 (which is yielded by inputting 2) I believe; which would mean this is not currently conforming to spec.

JS assumes that any integer other than 0 is considered truthy...  however, if 2 is returning 2 as truthy, then this submission may need to be reworked.

I think replacing äè with r¥, as I mentioned above, should solve the issue @JonthanAllan raised.

Your code was almost a cyclops program.

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.

Would it be acceptable to return lambda n:(2*n^2*n+3)**2-8*n-9, with a return value of 0 for cyclops numbers?

This yields TRUE for n = -1

@user2390246 this problem is clearly not intended for negatives- if it was, all accepting solutions would need to be negatives (and the way that python implements integers would mean that no solutions should accept in python)

@DreamConspiracy Can you explain more?

@SolomonUcko The rules specifically say that negative input is falsy and does not have to be evaluated.

@SolomonUcko negative numbers are typically stored in twos complement representation. Consider first fixed size integers (32 bit for example). Among other properties, TCR requires that the MSB is 1 in negative numbers, and 0 in positive. This would immediately require that all positive outputs are false. In python we have even more of a problem though. Negative numbers implicitly have an infinite sequence of 1s in the most significant direction. Good luck trying to find the middle of that

@user2390246 The problem was since edited to clarify that our code doesn't need to work for negatives. It could be handled for 2 bytes by appending >1.

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.

This is so fast, I think it deserves to be shown off by testing all numbers up to a large value: Try it online!

It should actually be even faster, @Deadcode. :-) Demonstrating it with inline assembly adds some overhead, but my old trick of jumping to a string of bytes (see e.g., this answer) has stopped working with TIO's compiler, and writing code to print the results directly in assembly is too much work to bother with. This is one of those unusual cases, though, where optimizing for size is not at odds with optimizing for speed. This is pretty much the way you'd write the code in asm if you were going for speed over size.

By consensus, it not unacceptable to return a status flag in an asm submission https://codegolf.stackexchange.com/a/165020/84624 and https://stackoverflow.com/questions/48381234/is-it-considered-bad-practice-to-use-the-flags-register-as-a-boolean-return-valu. If so, you could - 3 from your second answer.

Here's a clean way to return boolean results efficiently from inline asm - and the result

mul edx or imul edx saves 1 byte over imul eax, edx, and produces the same result in EAX.  (It clobbers EDX but we're done with it at that point.)  This is a size vs. speed tradeoff: one-operand mul/imul is 3 uops for 32-bit operand-size on Intel.

Also BTW, only the x86-64 SysV calling convention passes an arg in EDI, not i386 SysV.  Your first version doesn't depend on one-byte inc/dec and is actually valid 64-bit machine code as well, which would decode as lea eax, [rdi + 1] and so on since there aren't address-size prefixes.  Re: truthy/falsy: yes, comments on the meta Q&A Interpretation of Truthy/Falsey point out that in languages like x86 asm where jump-if-zero and jump-if-nonzero are on equal footing, you can choose which you want.

Besides, 0 is highly appropriate to indicate that it is a cyclops.

Regex (ECMAScript), 60 58 57 60 58 bytes
The input \$n\$ is in unary, as the length of a string of xs.
SPOILER WARNING: For the square root, this regex uses a variant of the generalized multiplication algorithm, which is non-obvious and could be a rewarding puzzle to work out on your own. For more information, see an explanation for this form of the algorithm in Find a Rocco number.
-2 bytes by allowing backtracking in the search for \$z\$
-1 byte thanks to Grimmy, by searching for \$z\$ from smallest to largest instead of vice versa
+3 bytes to handle zero
-2 bytes by moving the square root capture outside the lookahead
This works by finding \$z\$, a perfect square power of 2 for which \$n=2(n-z)+\sqrt{z}+1\$. Only the largest perfect square power of 2 not exceeding \$n\$ can satisfy this, but due to a golf optimization, the regex tries all of them starting with the smallest. Since each one corresponds to a cyclops number, only the largest one can result in a match.
^(x*)(?!(x(xx)+)\2*$)(x(x*))(?=(?=(\4*)\5+$)\4*$\6)x\1$|^$

Try it online!
^                 # N = tail
(x*)              # tail = Z, with the smallest value that satisfies the following
                  # assertions (which is no different from the largest value that
                  # would satisfy them, since no more than one value can do so);
                  # \1 = N - Z

(?!(x(xx)+)\2*$)  # Assert Z is a power of 2

# Assert Z is a perfect square, and take its square root
(x(x*))           # \4 = square root of Z; \5 = \4 - 1; tail = N - \1 - \4
(?=(\4*)\5+$)     # iff \4*\4 == Z, then the first match here must result in \6==0
(?=\4*$\6)        # test for divisibility by \4 and for \6==0 simultaneously

# Assert that N == \1*2 + \4 + 1. If this fails, then due to a golf optimization,
# the regex engine will backtrack into the capturing of \4, and try all smaller
# values to see if they are the square root of Z; all of these smaller values will
# fail, because the \4*\4==Z multiplication test only matches for one unique value
# of \4.
x\1$

|^$               # Match N==0, because the above algorithm does not

OP clarified that 0 should be truthy, so this currently doesn't solve the challenge.

Isn't a simple ^(1*)0\1$ enough?

@EmbodimentofIgnorance Only if the input were in binary. That would trivialize a lot of challenges; consistently using unary input where applicable is much more interesting.

JavaScript (Node.js), 20 bytes
p=>~p==(p^=p+1)*~p/2

Try it online!
Maybe this is correct, maybe.
Thanks Grimy, 1 byte saved.

JavaScript (Node.js), 32 bytes
f=(p,q)=>p&1?f(p/2,q+q|2):!(p^q)

Try it online!

JavaScript (Node.js), 34 bytes
p=>/^(1*)0\1$/.test(p.toString(2))

Try it online!

20

Test, not match

@edc65 Did you find out any failed testcase?

@tsh .test not .match

@ASCII-only Wow, sound reasonable... How can you read this?

@tsh read what lol

Japt,  25 19 10 9 bytes
¢êÅ©1¶¢èT

Thanks to @Shaggy for -1 byte
Try it online!

9 bytes

8 bytes

Perl 6, 23 bytes
{.base(2)~~/^(1*)0$0$/}

Try it online!
Regex based solution

Mathematica (Wolfram language), 32 31 bytes
1 byte saved thanks to J42161217!
OddQ@Log2[#+Floor@Sqrt[#/2]+2]&

Try it online!
Pure function taking an integer as input and returning True or False. Based on the fact (fun to prove!) that a number n is Cyclops if and only if n plus the square root of n/2 plus 2 rounds down to an odd power of 2. (One can replace Floor by either Ceiling or Round as long as one also replaces +2 by +1.) Returns True on input 0.

you can save 1 byte by using Log2[#+Floor@Sqrt...

and 1 more using √() instead of Sqrt[]

Is the byte count correct? TIO gives 32 bytes for the current program.

@mbomb007 aha, the TIO didn't incorporate J42161217's 1-byte savings. Fixed.

Was there a reason you didn't use what attinat suggested?

no, just laziness

Ruby, 24 bytes
->x{x+x+2==(1+x^=x+1)*x}

Try it online!

Nice. There might be a shorter version with different assignments and precedence, but I couldn't find any.

Japt, 8 bytes
¢ðT ¥¢Êz

Thanks to Luis felipe de Jesus Munoz for fixing my submission!
Try it Online!
Old regex-based solution, 15 bytes
¤f/^(1*)0\1$/ l

Returns 1 for true, 0 for false.
Try it Online!

Well played, I should really learn regular expressions sometime. :) +1

@Quintec Regex is awesome :)

Update: found shorter way :)

8 bytes

@LuisfelipeDejesusMunoz Thanks, that's a really nice use of the == operator!

I'll get your bounty setup for this on Monday; I'm not online over the weekend and, if I do it now, I'll only forget about it.

The 8 byte version fails for 1

Jelly,  8  7 bytes
-1 thanks to Erik the Outgolfer (use isPalindrome built-in, ŒḂ, instead of ⁼Ṛ$)
B¬ŒḂ⁼SƊ

A monadic Link accepting an integer which yields 1 (truthy) or 0 (falsey).
Try it online!
How?
B¬ŒḂ⁼SƊ - Link: integer             e.g. 1    9          13         119
B       - to base 2                      [1]  [1,0,0,1]  [1,1,0,1]  [1,1,1,0,1,1,1]
 ¬      - logical NOT (vectorises)       [0]  [0,1,1,0]  [0,0,1,0]  [0,0,0,1,0,0,0]
      Ɗ - last three links as a monad:
  ŒḂ    -   is a palindrome?             1    1          0          1
     S  -   sum                          0    2          1          1
    ⁼   -   equal?                       0    0          0          1

Looks like you actually had the clever idea before me, but its cleverness isn't obvious (Bċ0⁼1ȧŒḂ is also 8 bytes), ⁼Ṛ$ is the same as ŒḂ for -1. Also, you don't need to handle negative numbers.

Thanks Erik, the is palindrome built-in slipped my mind for some reason!

Actually, you can also use ṚƑ in its place nowadays, so you might want to remember it like that (the most important Ƒs).

C (gcc), 26 bytes
f(n){n=~n==(n^=-~n)*~n/2;}

Try it online!
Port of Neil's answer. Relies on implementation-defined ordering of operations.
C++ (clang), 38 bytes
int f(int n){return~n==(n^=-~n)*~n/2;}

Try it online!
Can't omit the types in C++, can’t omit the return in clang, otherwise identical.

I would prefer that C++ answers be differentiated from C answers by using return instead of the fragile and platform-dependent implicit accumulator return value exploit.

I would also like the rules to require standard-compliance, but they don’t, so not making use of this would just be bad golf. C++ (clang) requires the return, making this 38 bytes.

Then you can get around this by having C (gcc) and C++ (clang) in your answer instead of C (gcc) and C++ (gcc). I've now done that.

Brachylog, 8 bytes
ḃD↔Dḍ×ᵐ≠

This is a predicate that succeeds if its input is a Cyclops number and fails if its input is not a Cyclops number. Success/failure is the most fundamental truthy/falsey concept in Brachylog.
Try it online! Or, find all truthy outputs up to 10000.
Explanation
          Input is an integer
ḃ         Get its binary representation, a list of 1's and 0's
 D        Call that list D
  ↔       When reversed...
   D      It's the same value D
    ḍ     Dichotomize: break the list into two halves
          One of these halves should be all 1's; the other should contain the 0
     ×ᵐ   Get the product of each half
       ≠  Verify that the two products are not equal

This succeeds only when given a Cyclops number, because:

If the binary representation isn't a palindrome, D↔D will fail; in what follows, we can assume it's a palindrome.
If there is more than one zero, both halves will contain at least one zero. So the products will both be zero, and ×ᵐ≠ will fail.
If there is no zero, both halves will contain only ones. So the products will both be one, and ×ᵐ≠ will fail.
That leaves the case where there is exactly one zero; since we already know we have a palindrome, this must be the central bit. It will appear in one half, causing that half's product to be zero; the other half will contain all ones, so its product will be one. Then we have 1 ≠ 0, ×ᵐ≠ succeeds, and the whole predicate succeeds.

05AB1E, 8 (or 9) bytes
bD0¢sÂQ*

Try it online or verify all test cases.
Returns 1 if truthy; 0 or any positive integer other than 1 as falsey. In 05AB1E only 1 is truthy and everything else is falsey, but I'm not sure if this is an allowed output, or if the output should be two consistent and unique values. If the second, a trailing Θ can be added so all outputs other than 1 become 0:
Try it online or verify all test cases.
Explanation:
b     # Convert the (implicit) input-integer to a binary-string
 D    # Duplicate it
  0¢  # Count the amount of 0s
 s    # Swap to get the binary again
  ÂQ  # Check if it's a palindrome
 *    # Multiply both (and output implicitly)

  Θ   # Optionally: check if this is truthy (==1),
      # resulting in truthy (1) or falsey (0)

An arithmetic approach would be 10 bytes:
LoD<s·>*Iå

Try it online or verify all test cases.
Explanation:
Creates a sequences using the algorithm \$a(n) = (2^n-1)*(2*2^n+1)\$, and then checks if the input-integer is in this sequence.
L        # Create a list in the range [1, (implicit) input-integer]
 o       # For each integer in the list, take 2 to the power this integer
  D<     # Create a copy, and decrease each value by 1
  s·     # Get the copied list again, and double each value
    >    # Then increase each value by 1
  *      # Multiply the numbers at the same indices in both lists
     Iå  # Check if the input-integer is in this list
         # (and output the result implicitly)

Having 1 as truthy and all other numbers as falsy is acceptable for this challenge, since other languages (e.g. C and TI-BASIC) have similar truthy/falsy definitions (0/non-zero for both).  As long as what's considered truthy or falsy matches with the language's specifcations, then it's fair game.

Regex (ECMAScript), 53 47 bytes
-6 bytes thanks to both Deadcode and Grimy
^((?=(x*?)(\2((x+)x(?=\5$))+x$))(?!\2{6})\3x)*$

Try it online!
explanation by Deadcode
This regex takes its input in unary, as a sequence of x characters in which the length represents the number. Properties of its binary representation are handled indirectly, by doing math on its unary representation.
It works by looping the following operation, which is a subtraction at every step:

Trim the leftmost and rightmost 1 from the number's binary representation, if the 1 being trimmed from the left is immediately followed by another 1 or the full number is 101

If and only if the initial input was a cyclops number, it will be the next smallest cyclops number at every step of the loop, e.g. 1110111 → 11011 → 101 → 0. The regex matches if and only if the value is 0 at the end.
^                              # tail = N, the input number
(                              # While tail is odd and is >= 3, and has a leftmost "11"
                               # in its binary representation, trim off the leftmost and
                               # rightmost 1 from its binary representation. If it is a
                               # cyclops number, it will be the next smaller cyclops
                               # number on the next iteration.
    (?=
        (x*?)                  # Find the smallest \2 such that tail - 2*\2 satisfies the
                               # following assertion, i.e. that tail - 2*\2 = 2^k-1
                               # where k >= 2. In other words, assert tail is odd, and
                               # let \2 = (tail - 2^k + 1) / 2, where 2^k-1 has the
                               # largest value of k such that 2^k-1 <= tail. If tail is
                               # a cyclops number, then \2-1 will be the next smallest
                               # cyclops number;
                               # tail -= \2
        (                      # \3 = tool to make tail-1 = \2-1 (will be used later)
            \2                 # tail -= \2
            ((x+)x(?=\5$))+x$  # Assert tail = 2^k-1 where k >= 2
        )
    )
    (?!\2{6})                  # Assert that tail < 6*\2, which is a way of asserting
                               # that in tail's binary representation, the next 1 to the
                               # right of the one we'll be trimming is also 1. This
                               # prevents for example, trimming 10110111 -> 11011, which
                               # would give us a false positive. As a worst case example,
                               # let's say tail = 0b101111111111111111111111111111111111
                               # this would give us:
                               #             \2 = 0b001000000000000000000000000000000000
                               #           6*\2 = 0b110000000000000000000000000000000000
                               # So it's not quite exactly asserting that tail begins
                               # with "11" in its binary representation, and would
                               # continue looping in that case, but that doesn't matter
                               # because that number could never be trimmed into a
                               # cyclops number anyway. With any smaller value of tail
                               # that passes the other tests, we'd have:
                               #           tail = 0b101111111111111111111111111111111101
                               #             \2 = 0b000111111111111111111111111111111111
                               #           6*\2 = 0b101111111111111111111111111111111010
                               # and in this case tail >= 6*\2, so it stops the loop.
                               # On the other end of the scale is 0b101, which needs to
                               # be trimmed even though it doesn't have two leftmost 1
                               # bits in a row. And indeed, that works:
                               #           tail = 0b101
                               #             \2 = 0b001
                               #           6*\2 = 0b110
                               # In this case, it is just barely true that tail < 6*\2
                               # and the loop is allowed to continue one more step.
    \3x                        # tail = \2-1
)*
$                              # Assert that tail = 0 after the loop finished. This will
                               # be true iff N is a cyclops number. If it fails to match,
                               # backtracking cannot make it match, because everything in
                               # the loop is atomic.

In the course of fully commenting and proving your regex (not quite finished yet), I got it down to 50 bytes: ^((?=(x(x*?))(\3((x+)(?=\6$))+xx$))(?!\2{6})x\4)*$ (Try it online!)

Haskell, 32 bytes
f n=or[2*4^k-2^k-1==n|k<-[0..n]]

Try it online!

J, 22 19  17  15 14   bytes
-3 bytes thanks to BolceBussiere !
-4 bytes thanks to ngn!
-1 byte thanks to Traws!
J, 14 bytes
1=1#.(*:|.)@#:

Try it online!

-3 Bytes by using +/=<:@# instead of ,@0-:1-.~]

@BolceBussiere Of course, that's much better! Thanks!

#=1++/

(#=1++/)@(*|.)@#:

@ngn Thank you! Nice and simple code!

1=1#.1-(*|.)@#:

@ngn Addicted to J?

i don't know enough j to use it but it's fun to learn from other people's code by trying to shorten it

-1 byte 1=1#.(*:|.)@#:

@Traws Nice, thank you!

Ruby, 27 24 bytes
Convert to binary and check with a regex. Returns 0 if true, nil if false.
-3 bytes thanks to GB.
->n{"%b"%n=~/^(1*)0\1$/}

Try it online!
For two bytes more, there's a direct port of the Python solution:
->n{(2*n^2*n+3)**2==8*n+9}

Batch, 39 37 bytes
@cmd/cset/a"m=%1^-~%1,!(m/2*(m+2)-%1)

Explanation: A Cyclops number has the form \$ n = (2 ^ k + 1) (2 ^ { k - 1 } - 1) \$. The bitwise XOR then results in \$ m = 2 ^ k - 1 \$ from which we can recalculate \$ n = \lfloor \frac m 2 \rfloor ( m + 2 ) \$. This can then be used to test whether \$ n \$ was a Cyclops number.

R, 37 33 bytes
(x=scan())%in%(2*4^(n=0:x)-2^n-1)

Try it online!
R doesn't have a built-in for converting to binary, so I simply used one of the formulae from OEIS to calculate a list of terms from the sequence.
n<-0:x generates a generous list of starting values. 2*4^(n<-0:x^2)-2^n-1) is the formula from OEIS, and then it checks whether the input appears in that sequence using %in%.
-2 bytes by not having to handle negative inputs. -2 bytes by remembering I can change <- to =.

Excel, 97 63 Bytes
=A1=2*4^(ROUND(LOG(A1,4),0))-2^(ROUND(LOG(A1,4),0))-1

Calculates 2 numbers:

Twice the nearest Power of 4
>Num|Binary|2*Power4|Binary
>  1|     1| 2* 1= 2|    10
>  2|    10| 2* 4= 8|  1000
>  4|   100| 2* 4= 8|  1000
> 20| 10100| 2*16=32|100000

1 Plus the square root of the nearest Power of 4
>Num|Binary|1+√Power4|Binary
>  1|     1|1+  √1= 2|    10
>  2|    10|1+  √4= 3|    11
>  4|   100|1+  √4= 3|    11
> 20| 10100|1+ √16= 5|   101

Then subtract the second number from the first:

>Num|Binary|2*Power4|Binary|1+√Power4|Binary|a-b|Binary
>  1|     1| 2* 1= 2|    10|1+  √1= 2|    10|  0|     0
>  2|    10| 2* 4= 8|  1000|1+  √4= 3|    11|  5|   101
>  4|   100| 2* 4= 8|  1000|1+  √4= 3|    11|  5|   101
> 20| 10100| 2*16=32|100000|1+ √16= 5|   101| 27| 11011

And compare this result with the original number
Old Method
=DEC2BIN(A1)=REPLACE(REPT("1",1+2*INT(IFERROR(LOG(A1,2),0)/2)),1+IFERROR(LOG(A1,2),0)/2,1,"0")

Start with the Log-base-2 of A1 and round it down the nearest even number, then add 1.
Next create a string of that many "1"s, and replace the middle character with a "0" to create a Cyclops number with a binary length that is always odd, and the same as or 1 less than the binary length of A1
Then, compare it with the Binary representation of A1

C (gcc),  29 28  27 bytes
Saved 1 byte thanks to @ceilingcat
A port of the 21-byte JS answer by @tsh.
f(p){p=2*~p==~(p=-~p^p)*p;}

Try it online!

Jelly, 9 bytes
BŒḂaB¬S=1

Try it online!

Retina 0.8.2, 38 37 bytes
.+
$*
+`^(1+)\1
$+0
10
1
^((1+)0\2)?$

Try it online! Link includes test cases. Edit: After clarification, previous solution didn't handle zero correctly. Explanation:
.+
$*

Convert from decimal to unary.
+`^(1+)\1
$+0
10
1

Convert from unary to binary, using the method from the Retina wiki.
^((1+)0\2)?$

Check for the same number of 1s before and after the 0, or an empty string (which is how the above conversion handles zero).

Attache, 22 bytes
{Flip@_=_∧1=0~_}@Bin

Try it online!
Alternatives
27 bytes: {BitXor[2*_,2*_+3]^2=8*_+9}
27 bytes: {BitXor@@(2*_+0'3)^2=8*_+9}
27 bytes: {Palindromic@_∧1=0~_}@Bin
28 bytes: {BitXor[...2*_+0'3]^2=8*_+9}
28 bytes: {BitXor[…2*_+0'3]^2=8*_+9}
28 bytes: {Same@@Bisect@_∧1=0~_}@Bin
29 bytes: {_[#_/2|Floor]=0∧1=0~_}@Bin
30 bytes: Same@Bin@{_+2^Floor[Log2@_/2]}
30 bytes: {_[#_/2|Floor]=0and 1=0~_}@Bin

PHP, 74 bytes
function($x){return($c=strlen($a=decbin($x)))&1&&trim($a,1)===$a[$c/2|0];}

Try it online!
Or 61 bytes using Arrow syntax:
fn($x)=>($c=strlen($a=decbin($x)))&1&trim($a,1)===$a[$c/2|0];

Try it online!
Totally naïve non-mathematical approach, just strings.
function cyclops( $x ) {
    $b = decbin( $x );     // convert to binary string (non-zero left padded)
    $l = strlen( $b );     // length of binary string
    $t = trim( $b, 1 );    // remove all 1's on either side
    $m = $b[ $l / 2 |0 ];  // get the middle "bit" of the binary string
    return
        $l & 1 &&          // is binary string an odd length?
        $t === $m;         // is the middle char of the binary string the same as
                           // string with left and right 1's removed? (can only be '0')
}

Or 60 bytes based on @Chronocidal's algorithm above.
function($x){return decbin($x)==str_pad(0,log($x,2)|1,1,2);}

Try it online!

Pyt, 17 bytes
ĐļƖĐ⁺2⇹^⇹ᵮ₂2⇹^-⁻=

Try it online!
No string manipulation required
ĐļƖĐ⁺2⇹^⇹₂2⇹^-⁻=

Instruction
Stack
Note

Đ
n,n
implicit input (n); duplicate onto stack

ļƖ
n,k
take base-2 log of n and cast to integer (k)

Đ
n,k,k
duplicate k on stack

⁺
n,k,k+1
increment top of stack

2⇹^
n,k,2^(k+1)
raise 2 to the k+1 power

⇹
n,2^(k+1),k
swap the top two items on the stack

ᵮ₂
n,2^(k+1),k/2
cast top of stack to float, then divide by 2

2⇹^
n,2^(k+1),2^(k/2)
raise 2 to the k/2 power

-⁻
n,2^(k+1)-2^(k/2)-1
subtract and decrement

=
True/False
check for equality; implicit print

Thunno, \$ 8 \log_{256}(96) \approx \$ 6.58 bytes
bDZqs0c=

Attempt This Online!
Port of emirps's Vyxal answer.
Thunno P, \$ 9 \log_{256}(96) \approx \$ 7.41 bytes
bD0c1=sZq

Attempt This Online!
Port of Kevin Cruijssen's 05AB1E answer.
Explanation
bDZqs0c=  # Implicit input
bD        # Convert to binary and duplicate
  Zqs     # Check if it's a palindrome and swap
     0c=  # Is this equal to the count of 0s?
          # Implicit output

bD0c1=sZq  # Implicit input
bD         # Convert to binary and duplicate
  0c       # Count the number of "0"s in the string
    1=     # Is it equal to 1?
      sZq  # Swap and check if it's a palindrome
           # P flag multiplies them together
           # Implicit output

GolfScript, 31 35 26 bytes
-5 thanks to @DLosc
.!5*+2base..-1%=\{0=},,1=&

Link includes test cases.
Try it online!
Explanation
.!5*+2base..-1%=\{0=},,1=& | whole program
.!5*+                      | if the input is 0, make it 5 (smallest non-zero cyclops number)
     2base..               | push the binary version of the input
            -1%            | push the reversed version of the binary
               =           | is it equal to the non-reversed version?
                \{0=},,    | count the number of zeros
                       1=  | is it equal to 1?
                         & | are both of the above checks true?

Vyxal, 8 bytes
Π:Ḃ=$0O=

Try it Online!
Different approach from the other Vyxal answer.
Π        # binary of input
  Ḃ=     # the equality of the reversed version of it to itself (0 for non palindrome, 1 for palindrome)
       = # is equal to
 :  $0O  # the count of 0s in itself

Could potentially be golfed

Regex (ECMAScript), 65 59 57 58 bytes
+1 byte to handle 0 correctly
^((((x*)xx)\3)x)?(?=(\1*)\2*(?=\4$)((x*)(?=\7$)x)*$)\1*$\5

Try it online!
Works by asserting the input is of the form \$ (2^k - 1) (2^{k+1} + 1) \$. Ties Deadcode's answer but with a completely different algorithm.

APL(NARS), 57 char, 114 bytes
{⍵≤0:1⋄k=m←⌈k←2÷⍨≢v←{(2⍴⍨⌊1+2⍟⍵)⊤⍵}⍵:0⋄((,1)≡∪v∼⍦0)∧∼m⊃v}

test:
  f←{⍵≤0:1⋄k=m←⌈k←2÷⍨≢v←{(2⍴⍨⌊1+2⍟⍵)⊤⍵}⍵:0⋄((,1)≡∪v∼⍦0)∧∼m⊃v}
  ⎕fmt f¨0 1 5 12 27 85 101 119
┌8───────────────┐
│ 1 0 1 0 1 0 0 1│
└~───────────────┘

This below would be (modulus bugs) the function that would convert a positive integer number omega in one array of digits in base alpha:
{(⍺⍴⍨⌊1+⍺⍟⍵)⊤⍵}

Excel, 101 107 bytes
-6 bytes thanks to @Chronocidal.
=AND(ISEVEN(LOG(A1,2)),MID(DEC2BIN(A1),LEN(DEC2BIN(A1))/2+1,1)="0",LEN(SUBSTITUTE(DEC2BIN(A1),1,))=1)

Performs 3 checks:

Odd length

ISEVEN(LOG(A1,2))

Middle character is 0

MID(DEC2BIN(A1),LEN(DEC2BIN(A1))/2+1,1)="0"

There is a single 0

LEN(SUBSTITUTE(DEC2BIN(A1),1,))=1

Save 6 bytes by changing ISODD(LEN(DEC2BIN(A1))) to ISEVEN(LOG(A1,2))

C++ (gcc), 142 \$\cdots\$ 59 55 bytes
Saved 10 a whopping 21 23 bytes thanks to ceilingcat!!!
int f(int n){int c=__builtin_ctz(~n);n=(n>>c)+2==2<<c;}

Try it online!
Ungolfed:
bool is_cyclops(int n)
{
    int ones = 1;
    while ((n & 1) == 1)
    {
        ++ones;
        n /= 2;
    }
    while (--ones, n /= 2, (n & 1) == 1)
    {
        // nothing to do
    }
    return n == 0 && ones == 0;
}

C++ (clang), 72 68 67 60 bytes
As with Neil's and Grimmy's solutions, this works by asserting that the input is of the form \$(2^k-1)(2^{k+1}+1)\$.
5 bytes were dropped thanks to Arnauld, by changing ((x)+1) to -~(x) and ((x)-1) to ~-(x), and then changing n-a*-b to n+a*b. An additional 7 bytes were dropped thanks to ceilingcat.
int f(int n){int z,k=1;while((z=n+~-k*~(k*=2))>0);return!z;}

Try it online!
Alternative 60 byter:
int f(int n){for(int o=n,k=1;n>0;)n=o+~-k*~(k*=2);return!n;}

Try it online!
Ungolfed:
bool is_cyclops_number(int n)
{
    for (int k=1;; k*=2)
    {
        int z = n - (k - 1) * (k*2 + 1);
        if (z == 0)
            return true;
        if (z < 0)
            return false;
    }
}

C (gcc) - x86 & most others, 41 34 bytes
Returns zero for true and nonzero for false.
k;f(n){for(k=1;n+~-k*~(k*=2)>0;);}

Try it online!
This demonstrates why I hate the implicit accumulator return value exploit that is commonly used in C submissions and less often in C++ submissions. It's fragile and very much architecture dependent. Here, it depends upon the comparison operator > not changing the value of the accumulator.
I did notice something quite curious regarding the ARM gcc assembly code. It appears that the return value hack is being explicitly supported, by copying the intermediate result r3, which wasn't stored into any variable, into the accumulator r0 once the loop is done:
        cmp     r3, #0
        bgt     .L2
        nop
        mov     r0, r3

Similarly on PowerPC gcc, where register 3 carries the return value:
        cmpwi 7,9,0
        bgt 7,.L2
        mr 3,9

Similarly on RISC-V gcc, where a0 carries the return value:
       add   a5,a5,a4
       bgtz  a5,10144 <f+0x12>
       nop
       mv    a0,a5

In fact, it appears the trick works on all but one of the architectures on godbolt. On MSP430 gcc 6.2.1, it yields the code with the equivalent of return 0 (as the return value is passed through R12):
        MOV.B   #0, R12
        CMP.W   R13, R12 { JL .L2
        NOP

VBA, 41 36 Bytes
x=2^Int([Log(A1,4)]):?[A1]=2*x^2-x-1

Run in the Immediate window, with Explicit Declaration turned off.  Input is cell A1 of the active sheet.  Outputs True/False to the immediate window.
Uses the same logic as my Excel Answer to find the Cyclops number of the same number of bits (or 1 bit shorter if there are an even number!) and then compares that with the input.
Saves some bytes when calculating Cyclops numbers by reducing them to the form y = 2x^2 - x - 1 (where x = n-1 for the nth Cyclops number, or x = 2^Int(Log([A1])/Log(4)) to find the largest Cyclops number with a lesser-or-equal number of bits) and storing x in a variable
(-5 Bytes thanks to Taylor Scott!)

Instead of converting the log's base using log division, you can change it directly using [...] notation as [(Log(A1,4)]

Stax, 9 7 bytes
ç8┤-½Θ■

Run and debug it

Haskell, 82 bytes
import Text.Printf
(`all`[(==)<*>reverse,("0"==).filter(<'1')]).flip($).printf"%b"

And a port of xnor's Python solution:
Haskell, 47 bytes
import Data.Bits
\n->(2*n`xor`(2*n+3))^2==8*n+9

K (ngn/k), 19 bytes
{1=(~x)+/~a&|a:2\x}

Try it online!
{ } function with argument x
2\x the bits of x
a: assign to a
a&|a and between a and its reverse (|a)
~ not
+/ sum
(~x) use "not x" as the initial value for the sum. this is to correct for 2\x returning an empty list of bits when x is 0
1= compare with 1

Gaia, 10 9 bytes
b:ṭ¤0C1=∧

Try it online!
Verify All Test Cases
b:		% convert to binary and dup
  ṭ		% is it a palindrome?
        ∧	% and
   ¤0C		% is the count of zeros
      1=	% equal to 1?
		% implicit print top of stack

dc, 62 60 bytes
[2~rd0<B]dsBx1kz2/szsi[1r-si]sC[zlz=Cli*siz0<M]sMz1=Cz1<Mlip

Try it online!
dc has no native truthy/falsy values (conditionals either execute a macro or they don't); using 1 for truthy and 0 for falsy, I hope that's ok.
[2~rd0<B]dsBx          # Basic breakdown into binary. Every digit is a stack entry. Luckily this
                       # also leaves an extra 0 on the stack.
1k                     # Set precision to one - needed it at 0 for the binary-ifier.
z2/sz                  # Divide the stack depth by 2 and store it in 'z'. This is why we're lucky
                       # that the binary-ifier leaves an extra bit on the stack! Numbers with even
                       # numbers of binary digits will now have an odd number & this value will be
                       # (whatever).5 which... isn't a valid stack depth.
si                     # Seed 'i' which is our truthiness register w/ that extra 0
[1r-si]sC              # Macro 'C' toggles the top of stack between 0 and 1 by subtracting it from 1.
                       # It stores this in 'i'. This is the only way 'i' ever becomes 1.
[zlz=Cli*siz0<M]sM     # First we test if we're at the position of the stack that matches up with
                       # 'z', and run 'C' if so. Thus, if we're in the 'Cyclops' position (the
                       # middle), we'll flip that from a 0 to a 1 or vice versa. Next we load 'i'
                       # and multiply it by top of stack, putting that back in 'i'. For the first half
                       # this whole thing does nothing but multiply stuff by zero. In the middle
                       # position (if there is one) it sets 'i' to 1 if it's a zero. For the rest of
                       # the digits, it multiplies by '1' if things are ok, and '0' if there's another
                       # (Cyclops-invalidating) zero.
z1=Cz1<M               # 1 and 0 don't work w/o special treatment. Run 'C' if it's one of these,
                       # otherwise start 'M'
lip                    # Print 'i'

Golfed off two bytes because my brain was fried and I was using a wasteful, convoluted method of toggling between 1 and 0.

Zsh --extendedglob, 30 bytes
>$[[##2]$1]
<`ls|rev`~*0*0*~1#
Attempt This Online!
Outputs via exit code (0 = is a cyclops number, 1 = not a cyclops number).

> - create the file

$[[##2]$1] - the input in base 2

<`ls|rev`~00*~1# - try to find a file that matches this pattern:

`ls|rev` - the file in reverse (i.e. palindromic)
~ - but not this pattern

*0*0* - more than one 0

~ - and not this pattern either

1# - one or more 1s

The exit code depends on whether or not the pattern matched and the file could be found.

Burlesque, 21 bytes
b2JXXRA'0==j'0CN1==&&

Try it online!
b2   # As binary
J    # Duplicate
XX   # Split into chars (RA is supposed to work with strings but doesn't)
RA   # Get middle
'0== # Is 0
j    # Reorder stack
'0CN # Count of 0s
1==  # ==1
&&   # And

Shorter, but sadly doesn't work for zero case because 2dg returns empty list
Burlesque, 16 bytes
2dgJRAj0CN-.||n!

Try it online!
2dg # Base 2 as list of digits
J   # Duplicate
RA  # Get middle
j   # Reorder stack
0CN # Count 0s
-.  # Decrement (i.e 1 -> truthy, else falsy)
||n!# not or (Check both zero)

Erlang 37 bytes
f(x)->Y=2*X bxor (2*X+3),Y*Y==8*X+9.

Vyxal, 9 bytes
b0₌O€vL≈=

Try it Online!
Output 0 → False, 1 → True

b         # To binary array
 0        # Push 0
  ₌       # Parallel apply next two operators:
   O      #   Count how many "0" and
    €     #   Split at "0"
     vL   # Lengths of parts
       ≈  # If its equal return 1
        = # If its equal number of zeroes, return 1, else 0

Swift 5.7, 60 bytes
{nil != (try?#/(1+)0\1/#.wholeMatch(in:String($0,radix:2)))}

SwiftFiddle link
Swift 5.7 introduced Regex literals, delimited by #/.../#. This code attempts to match the regex (1+)0\1 against the string, and returns whether or not it succeeded. Input may be any BinaryInteger.
I'm not certain that this is shorter than bit manipulation, but this is shorter than the existing answer.

Vyxal, 55 bitsv2, 6.875 bytes
b†Ḃ₍⁼∑≈

Try it Online!
Bitstring:
0111000000100000010011101011101001010010110100100111000

b†Ḃ₍⁼∑≈
b†       # Convert to binary, then invert each bit
  Ḃ      # Push the list of inverted bits and its reverse
   ₍  ≈  # is each item in the list equal?
    ⁼    # does the reverse of the inverted bits equal the inverted bits
     ∑   # sum of the bits

Created with the help of Luminespire.
7 byter (before encoding) with a completely different method.
Edit: Apparently this is a port of Jelly but I didn't realize
Since the equality check can only be 0 or 1, and the sum of the inverted bits is always at least 1 for any nonzero number, the values can only be equal if there is exactly one "1" in the inverted binary representation and that "1" is directly in the middle

Java, 96 bytes
n->{String[]a=Integer.toBinaryString(n).split("0");return n==0||a.length==2&&a[0].equals(a[1]);}

Try it online!

Factor, 69 bytes
: f ( n -- ? ) >bin [ dup reverse = ] [ [ 48 = ] count 1 = ] bi and ;

Try it online!

Java (OpenJDK 8), 135 130 bytes
Uses the Formula described here: A129868
(n)->java.util.stream.IntStream.range(0,16).map(r->((Double)(Math.pow(2,2*r+1)-(Math.pow(2,r)-1)-2)).intValue()).anyMatch(c->c==n)

Try it online!

Why do you say it doesn't work with all positive integers? It works fine up to a million, and I see no reason why it'd stop working.

https://codegolf.stackexchange.com/questions/181128/is-it-a-cyclops-number-nobody-knows/181174?noredirect=1#comment436477_181128
"...any positive integer can be tested". Example where it wont work anymore: 2096127. This is due to that i only test the first 11 of the OEIS A129868 Numbers. could do more maybe, but it will not work vor ANY positive integer i think

Okay, so this doesn't actually answer the problem, you should edit it to make it work or delete it. Marking an answer as non-competing isn't a free pass, it should still be valid.

It's funny how you first say everything is fine, and after i point you where the OP post that limit (that wasn't really defined before this answer was posted) you aggressively force to make it work now or deleting it without seemingly to know the timeline between answer and the point it was invalid :P

Sorry, I didn't mean to come across as aggressive. I also didn't say everything was fine, I just asked to be sure whether the answer was valid. Also the timeline isn't really relevant, if the answer is currently invalid it should be fixed or deleted.

Currently it is unkown if this or any other answer is valid because OP don't really defined what he meant with any positive integer as a integer could be 2 things, one has a maximum value the other not. And after my last change it is working with the 32-bit signed Integer

Let us continue this discussion in chat.

Swift, 161 bytes
func c(a:Int)->Int{
    let b=String(a,radix:2)
    let f=b.firstIndex(of:"0")
    return a>=0 && f==b.lastIndex(of:"0") && f?.encodedOffset==b.count/2 ? 1 : 0
}

Try it online!

Perl 5 -p, 32 bytes
$_=(sprintf'%b',$_)=~/^(1*)0\1$/

Try it online!

Java, 201 bytes (compilable)
Hmm, a different approach in java, runnable on commandline (so there is much to cut out).
class Z{public static void main(String[]a{a=Integer.toBinaryString(Integer.valueOf(a[0])).split("0");System.out.println(a.length==0?1:(a.length!=2?1:a[0].length()-a[1].length()+a.length-2)==0?1:0);}}

prints 0 for non cyclops and 1 for cyclops numbers.

Welcome to PPCG! I think you can remove public . Is there a ) missing after String[]a? a.length==0 -> a.length < 1, again later (maybe?).

PHP
The shortest code should be this:
preg_match('`^(?<l>1*)0\k{l}$`', decbin($n));

Here the script to test it:
$inputs = [
    0,
    1,
    5,
    9,
    10,
    27,
    85,
    101,
    111,
    119,
];

function isCyclop($n) {
    return preg_match('`^(?<l>1*)0\k{l}$`', decbin($n));
}

foreach ($inputs as $input) {
    echo "$input : ".(isCyclop($input)?'truthy':'falsy').PHP_EOL;
}

Perl 6 (26 bytes)
{so .base(2)~~/^(1*)0$0$/}

You can remove the so, since the output can just be truthy/falsey, but it ends up the same as my answer

Pip, 87 bytes
a:qTa<=1{((a%2)=0)?(x:"0".x)(x:"1".x)a//:2}1=a?x:"1".xsc:x^"0"x=0|#x%2=1&(c0)=(c1)&#c=2

Try it online!

Try a simpler approach next time.

Pip, 15 bytes
YTBa^0 2=#y&$=y

Try it online!
A much shorter pip solution.
Explanation
YTBa^0 2=#y&$=y a → input integer
YTBa^0         Yank binary representation of a into var y, split on 0's
       2=#y     Length of y = 2?
           &$=y and all items of y are equal?
                Implicit output of boolean

><>, 45 bytes
!v:2%$2,:1%-:1(?!
1\~
*>l2=?vl3=?0${*
$0=*n;>

Try it online!

Java 8, 66 69 bytes

-3 bytes thanks to @ceilingcat !

n->{int r=0,i=0;for(;i<16;)r+=n-~(1<<i)==1<<i+++i?1:0;return r>0;}

Try it online!
Don't hesitate to ask if this needs any explanation!

Alternative solution really close using Streams (70 bytes) :
n->"0123456789:;<=>?".chars().anyMatch(e->n-~(1<<e-48)==1<<2*(e-48)+1)

Thunno 2, 8 bytes
ḃDḲ=s0c=

Attempt This Online!
Port of emirps's Vyxal answer.
Explanation
ḃDḲ=s0c=  # Implicit input
ḃD        # Convert to binary; duplicate
  Ḳ=s     # Check if palindrome; swap
     0c=  # Equals the count of 0s?
          # Implicit output

Uiua, 17 characters (32 bytes UTF-8)
↥↧≍⇌.∶=1/+¬.⋯∶=0.
Explanation of ungolfed version:
↥⊃(↧⊃(≍⇌.)(=1/+¬)⋯)(=0)
↥⊃                   (=0)  # n is zero, or
                  ⋯       # the binary expansion of n
   ↧⊃      (=1/+¬)         # sums to 1 when all its bits are flipped
   ↧⊃(≍⇌.)                # and matches itself reversed

Japt, 8 bytes
Adding to the collection of 8-byte Japt solutions; can't seem to come up with anything shorter.
¢¶¢Ôp¢èT

Try it (Includes all test cases)
¢¶¢Ôp¢èT     :Implicit input of integer U
¢            :Convert to binary
 ¶           :Check for equality with
  ¢Ô         :  Convert U to binary and reverse
    p        :  Repeated
     ¢è      :    Convert U to binary and count the occurrences of
       T     :      0

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
It's Halloween again!
Problem Description
We all love a Twix (because it is the best candy), but this is the kids' first Halloween --- we gotta grab at least one of each type of candy for them. Each Halloween all the residents of Numberline avenue send out an email saying what types of candy they'll be giving away this year.
Oh! And we live in a 1D world.
Being exceptionally lazy in some ways and not in others, we've made a map of the houses giving their positions along the street. We also noted the types of candy they have. Here's the map we made for this year:
 [(-2, {"Kisses", "KitKats"}),
 (1, {"KitKats", "Peanut Butter Cups"}),
 (6, {"Kisses", "Twix"}),
 (9, {"Skittles"}),
 (10, {"Twix"})]

For the sake of the kids' little legs, we need to find the shortest walk starting at any house in the neighborhood to gather at least one of each type of candy.
Examples
At the request of a couple users (including Shaggy), I'll toss in some worked examples. Hopefully this clears things up. :)
Input:
 [(-2, {"Kisses", "KitKats"}),
 (1, {"KitKats", "Peanut Butter Cups"}),
 (6, {"Kisses", "Twix"}),
 (9, {"Skittles"}),
 (10, {"Twix"})]

Output:
[1, 2, 3]

Another map and solution...
Input:
[(-3, {"KitKats", "Twix"}),
(-1, {"Hundred Grands"}),
(3, {"Kisses"}),
(12, {"Hundred Grands", "Twix", "KitKats"})]

Output:
[0, 1, 2]

We could begin at the coordinate 9 house collecting candies to at houses 6 and 1. That fills the candy quota by walking 8 units, but is it the shortest solution?
Rules
Entries must take in a similarly structured single argument to the example and output the indices of the houses to visit in the shortest solution.
Typical code golf rules apply: shortest correct solution in bytes wins!
P.S. This was an interview question given to me by one of the world's largest tech companies. If you don't like golf, try finding an O(k*n) time solution where k is the number of candy types and n is the number of houses.
Edit
As Jonathon Allan pointed out, some confusion exists around what "indices" means in this case. We want to output the houses positions in the argument  list and not their coordinates on the lane.

You're right, thank you!

This is in need of a worked example and some test cases.

Can we take two arguments; a list of house numbers and a corresponding list of candy types?

Two questions: are the numbers guaranteed to be in order in the input? Can the strings contain digits? I have a working solution, but if the input isn't in order it is incorrect, and if the strings will never contain digits, I can golf a few bytes off. And as mentioned by @Shaggy, this can use some more test cases with the expected output. (PS: with the example, walking houses 1, 6 and 9 is indeed the shortest solution of 8 walking units.)

@KevinCruijssen Neither: output the indices of the houses to visit in the shortest solution

@Adám Ah, missed that part. Thanks! I'll delete my second comment.

I've VTCed this as unclear until my comment above has been addressed. Please ping be when it has so I can retract my vote or cast my vote to reopen.

I assumed "indices" and "positions" were synonymous (i.e. that the addresses on Numberline Avenue would be what we should return) is that wrong?

@Shaggy I agree! I'll throw some in. Thank you.

@KevinCruijssen Great questions! The numbers are guaranteed to be in order in the input. And I'll allow the assumption that the strings contain no digits as all the candies I know with numbers spell them out (Hundred Grands, and Three Musketeers). :)

@Shaggy I've added some more structure the the solution with examples. :)

VTC retracted. Although, it could still benefit from a step-by-step example.

Hmm.. your first example outputs the house numbers 1, 6, 9, but your second example outputs the indices 0, 1, 2 (for -3, -1, 3). So one of the two outputs is incorrect, but which one? I personally think outputting the house numbers themselves makes the most sense tbh. Although your rules state to output the indices.. Another possibility is to allow both. Either output the housenumbers, or the 0- or 1-indexed indices. :)

nitpick: these aren't "worked examples" - they're just testcases

Python 2, 133 130 127 bytes
def f(l):r=range(len(l));v,c=zip(*l);print min((v[j]-v[i],r[i:j+1])for i in r for j in r if s(*c)==s(*c[i:j+1]))[1]
s={0}.union

Try it online!

Jelly, 16 bytes
ŒPṪ€ẎQLƲÐṀẎISƊÞḢ

A monadic Link accepting the input as described in a list sorted from lowest to highest Numberline Avenue houses (if we need to accept any ordering we can prepend an Ṣ) which yields the shortest path starting at the lowest numbered house and travelling up the Avenue.
Try it online!
If we want to find all such shortest paths replace the trailing bytes, ÞḢ, with ÐṂ; this is also 16 bytes.
How?
ŒPṪ€ẎQLƲÐṀẎISƊÞḢ - Link: list of [index, candies]
ŒP               - power-set
        ÐṀ       - keep those for which this is maximal:
       Ʋ         -   last four links as a monad:
  Ṫ€             -     tail €ach -- this removes the candies lists from the current list
                 -                  and yields them for use now
    Ẏ            -     tighten (to a flat list of candies offered by these hoses)
     Q           -     de-duplicate (get the distinct candies offered)
      L          -     length (how many distinct candies are on offer)
              Þ  - sort (now just the indexes of remaining sets due to Ṫ) by:
             Ɗ   -   last three links as a monad:
          Ẏ      -     tighten (to a flat list of indexes since Ṫ leaves a list behind)
           I     -     incremental differences (distances between houses)
            S    -     sum
               Ḣ - head (get the first)

Nice. For your explanation, I think you mean maximal for the second quick.

Yep that I did.

05AB1E, 22 bytes
æʒ€θ˜I€θ˜åP}€€нD€¥OWQÏ

Assumes the numbers in the input-list are sorted lowest to highest.
If more than one solution is found, it will output all of them.
Try it online.
Explanation:
æ            # Get the powerset (all possible combinations) of the (implicit) input-list
 ʒ           # Filter this list of combinations by:
  €θ         #  Get the last items of each (the list of strings)
    ˜        #  Flatten the list
  I          #  Get the input-list again
   €θ˜       #  Get the last items of each (the list of strings) flattened as well
      å      #  Check for each if it is in the list of strings of this combination
       P     #  Check if all are present
 }           # Close the filter (we now have all combinations, containing all unique strings)
  €€н        # Only leave the first items of each item in the combination (the integers)
     D       # Duplicate this list
      €¥     # Get the deltas (forward differences) of each
        O    # Sum these deltas
         W   # Get the lowest sum (without popping the list)
          Q  # Check for each if it's equal to this minimum
           Ï # And only leave the list of integers at the truthy indices
             # (which are output implicitly as result)

Perl 6, 70 bytes
{grep({.[@^i;1]⊇.[*;1]},combinations ^$_).min:{[-] .[@^i[*-1,0];0]}}

Try it online!

Haskell, 343 372 bytes
Thanks to @ASCII-only for improvements, there's also a 271 bytes variant he proposed in the comments :)
import Data.List
import Data.Function
f s=subsequences(map(\a@(x,y)->(x,y,[(a`elemIndices`s)!!0]))s)
g f s=if f*s<=0 then f+abs f+abs s else f+abs(f-s)
h=foldl(\(a,b,c)(d,e,f)->(g a d,nub(b++e),c++f))(0,[],[])
i s=map h(filter(not.null)s)
l m=filter(\(_,x,_)->length x==(maximum$map(\(_,x,_)->length x)m))m
m=minimumBy(compare`on`(\(p,_,_)->p))
n s=(\(_,_,l)->l)$m$l$i$f s

Try it online!

Ungolfed
import Data.List
import Data.Function

allPaths :: [(Integer, [String])] -> [[(Integer, [String], [Int])]]
allPaths xs = subsequences(map (\a@(x,y) -> (x,y,[(a`elemIndices`s) !! 0])) s)

pathLength :: Integer -> Integer -> Integer
pathLength f s = if f*s <= 0 then f + abs f + abs s else f + abs(f - s)

traversePath :: [(Integer, [String], [Int])] -> (Integer, [String], [Int])
traversePath = foldl (\(n1, a1, c1) (n2, a2, c2) -> (pathLength n1 n2, nub (a1 ++ a2), c1 ++ c2)) (0, [], [])

allTraversedPaths :: [[(Integer, [String], [Int])]] -> [(Integer, [String], [Int])]
allTraversedPaths xs = map traversePath (filter (not . null) xs)

getCompletePaths :: [(Integer, [String], [Int])] -> [(Integer, [String], [Int])]
getCompletePaths m = filter (\(_,x,_) -> length x == ( maximum $ map (\(_,x,_) -> length x) m)) m

getFastestPath :: [(Integer, [String], [Int])] -> (Integer, [String], [Int])
getFastestPath = minimumBy (compare `on` (\(p, _, _) -> p))

getPath :: [(Integer, [String])] -> (Integer, [String], [Int])
getPath xs = (\(_,_,l) -> l) getFastestPath $ getCompletePaths $ allTraversedPaths $ allPaths xs

First attempt

you should only return the third element of that tuple, and you have an extraneous newline after your imports

315? (still have to return only third element though)

well actually... it doesn't even work on the second testcase

so yeah you can't hardcode the length

358

also how does the path length work? seems like it takes in length and new point - which doesn't factor in distance between the points at all

might work correctly now, idk

271?

Wups, you're totally right, really appreciate the feedback!

i still think the path length is wrong :|

234?

230?

O(k*n) time solution, with O(k*n) space
Let \$x_i\$ be the position of the \$i\$th house (where \$0 \le i < n\$, and \$x_i\$ are sorted) and \$c_i\$ be the list of candies offered by the \$i\$th house.
Observe that if we have a path from house \$i_1\$ to \$j_1\$ that gets all candy types, then for all \$i_0 < i_1\$, there is such a path from \$i_0\$ to \$j_0\$ where \$i_0 \le j_0\$.
Thus, our algorithm is:
// A[k] is the number of each candy we get from the first k houses
A := array of n bags
A[0] := {}
for k := 0 to n - 1
  A[k] := A[k - 1] + c[k - 1]
end
best_distance := ∞
best_i := -1
best_j := -1
// Find the range [i, j] such that we get all candy types
j := n
for i := n - 1 to 0
  while j > i and (A[j - 1] - A[i]) has all candy types
    j := j - 1
  end
  if (A[j] - A[i]) does not have all candy types then continue end
  distance = x[j - 1] - x[i]
  if distance < best_distance then
    best_distance = distance
    best_i = i
    best_j = j
  end
end
return best_i ..^ best_j

The construction of \$A\$ takes \$O(k)\$ time for each element, or \$O(nk)\$ time (and space) total. The outer loop for computing the best distance executes \$n\$ times. The inner loop can execute up to \$n\$ times in one iteration, but the body is executed at most \$n\$ times, so the condition is checked \$O(n)\$ times; thus, the inner loop accounts for a total of \$O(nk)\$ time. The rest of the outer loop body takes \$O(k)\$ time as well. Hence, our algorithm takes \$O(nk)\$ time and space.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Cycles on the torus
Challenge
This challenge will have you write a program that takes in two integers n and m and outputs the number non-intersecting loops on the n by m torus made by starting at (0,0) and only taking steps up and to the right. You can think of torus as the grid with wraparound both at the top and the bottom and on the sides.
This is code-golf so fewest bytes wins.
Example
For example, if the input is n=m=5, one valid walk is
(0,0) -> (0,1) -> (0,2) -> (1,2) -> (2,2) -> (2,3) -> (2,4) ->
(2,0) -> (3,0) -> (4,0) -> (4,1) -> (4,2) -> (4,3) ->
(0,3) -> (1,3) -> (1,4) ->
(1,0) -> (1,1) -> (2,1) -> (3,1) -> (3,2) -> (3,3) -> (3,4) -> (4,4) ->
(0,4) -> (0,0)

as shown in the graphic.

Some example input/outputs
f(1,1) = 2 (up or right)
f(1,2) = 2 (up or right-right)
f(2,2) = 4 (up-up, up-right-up-right, right-right, right-up-right-up)
f(2,3) = 7
f(3,3) = 22
f(2,4) = 13
f(3,4) = 66
f(4,4) = 258

I was willing to bet that this sequence was on OEIS for at least $m=n$, but apparently it's not (yet).

I think a torus also has a left-right wraparound. Should we assume it only has up-down wraparound instead? The example image doesn't seem to imply as such.

@EriktheOutgolfer The image does show the orange path wrapping around from right to left, doesn't it?

@Arnauld Yes, but it doesn't look consistent with the challenge's description ("You can think of torus as the grid with wraparound both at the top and the bottom.")

@EriktheOutgolfer That's true. And now that you mention it, the blue path is wrong. It should first wraparound from right to left and then from top to bottom.

I'm confused. f(1,1) should also admit "up-right" and "right-up" as paths, for a total of 4, and there are plenty of other paths in the other examples that seem like they exist but aren't listed.

@imallett, for f(1,1), starting at (0,0) and taking a step up places you at (0,1) = (0,0), completing the loop.  Your suggestion of "up-right" would return you to (0,0) after the first step and again after the second step (two concatenated loops).

i really like the idea of this puzzle but im super confused. on 2x2 for example... do the loops you get by "shifting" the starting point not count? i would imagine there were three different "up-up" paths that would be loops on a torus. thanks.

Always start at (0,0). So loops you get by shifting the starting point don’t count.

I'm a little confused, what counts as a loop?  In the shown image I can only see one loop, but we could easily make a bunch of loops, but they would always intersect since we need to start at 0,0.  It seems like we care more about the length of one loop?  But I can't figure out what we want even with the tests.

We want exactly one (non-intersecting) loop starting at (0,0). That is the coordinates only equal (0,0) on the first and last step and are all distinct in the middle.

Jelly, 28 bytes
ạƝ§=1Ȧ
²‘p/’ŒPÇƇḢÐṂ%⁸QƑƇṪÐṂL

A monadic Link accepting a list, [m,n], which yields the count.
TIO-jt1qe1v9 ...although there is little point, it's way too inefficient.
(I can't even run [2,3] locally with 16GB ram)!
How?
Brute force - creates coordinates of a tiled version big enough then filters the power-set of these points to those paths with neighbours only increasing by one in a single direction, then filters to those starting at a minimal coordinate (i.e. the origin) and, at the same time, removes this start coordinate from each. Then uses modulo arithmetic to wrap back to a torus and filters out any containing duplicate coordinates (i.e. those containing intersections) and, finally, filters to those with minimal ending coordinates (i.e. ending back at the origin) and yields the result's length.
ạƝ§=1Ȧ - Link 1: all neighbours differ by 1 in exactly one direction
 Ɲ     - for neighbours:
ạ      -   absolute difference
  §    - sum each
   =1  - equal to one (vectorises)
     Ȧ - any and all? (falsey if empty or contains a falsey value when flattened)

²‘p/’ŒPÇƇḢÐṂ%⁸QƑƇṪÐṂL - Main Link: list of integers, [m,n]
²                     - square (vectorises) -> [m*m, n*n]
 ‘                    - increment (vectorises) -> [m*m+1, n*n+1]
   /                  - reduce with:
  p                   -   Cartesian product
    ’                 - decrement (vectorises) -> all the coordinates of an m*m by n*n grid
                      -                           including [0, 0] and [m*m, n*n]
     ŒP               - power-set -> all paths going either up OR right at each step, but not
                      -              necessarily by only 1, and
                      -              necessarily both up and right (e.g. [...[1,3],[5,7],[6,2],...])
        Ƈ             - filter keep those for which:
       Ç              -   call last Link (1) as a monad
                      -              ...now all remaining paths do only go in steps
                      -              of one up or one right
          ÐṂ          - filter keep those minimal under:
         Ḣ            -   head - removes the 1st coordinate from each and yields them for the filter
                      -          ...so only those which started at [0,0] but without it
            %⁸        - modulo by the left argument ([m,n]) (vectorises)
                Ƈ     - filter keep those for which:
               Ƒ      -   is invariant when:
              Q       -     de-duplicated
                      -          ...so no repetitions of torus coordinates (and we already removed
                      -          the first [0,0] which must be present exactly twice)
                  ÐṂ  - filter keep those minimal under:
                 Ṫ    -   tail
                      -          ...so only those which ended at [0,0]
                    L - length

Python 2, 87 bytes
f=lambda m,n,z=0,l=[]:z==0if z in l else sum(f(m,n,(z+d)%m%(n*1j),l+[z])for d in(1,1j))

Try it online!
The interesting thing here is using a complex number z to store the coordinate of the current position. We can move up by adding 1 and move right by adding 1j. To my surprise, modulo works on complex numbers in a way that lets us handle the wrapping for each dimension separately: doing %m acts on the real part, and %(n*1j) acts on the imaginary part.

Nicely done. FWIW, my best attempt without using a complex number is 91 bytes in Python 3.8.

@Arnauld Interesting idea with the k:=x+y*m. It makes me wonder if it would be shorter to use k directly for (x,y), using x+y*m rather than x+y*1j. Too bad Python 3 doesn't allow complex modulus.

@Arnauld 87 bytes: https://tio.run/##XckxDoIwFIDh3VN0wfTRR0JbBkMsJ@ASGGkkry0NspgYr14lDhaHf/jyx8d6m4M@xSUla9zgL9eBeQxIpkZn6pbOcrLMdR0d5ejuI7N825yEh4L7MgD2rXFPVZYE4jtJVC8qfPUJe0hxmcLKLZcoAQ4/qUzqTzqT3klhs3u5mk3pDQ

This approach saves 5 bytes in JS. :)

JavaScript (ES6), 67 bytes
This shorter version is derived from a Python 3.8 alternate version found by @xnor. However, this works only for \$m\times n<32\$ in JS.
Takes input as (m)(n).
m=>n=>(g=(k,l)=>l>>k&1?!k:g((k+m)%(m*n),l|=1<<k)+g(k-~k%m-k%m,l))``

Try it online!
To have it work for any input, we could use BigInts for 73 bytes:
m=>n=>(g=(k,l=k)=>l&(b=1n<<k)?!k:g((k+m)%(m*n),l|=b)+g(k-~k%m-k%m,l))(0n)

Try it online!

JavaScript (ES6),  76 73  72 bytes
Takes input as (m)(n).
m=>n=>(g=(x,y)=>g[x+=y*m]?!x:g(-~x%m,y,g[x]=1)+g(x%m,-~y%n)+--g[x])(0,0)

Try it online!
Commented
m => n => (         // m = width; n = height
  g = (             // g is a recursive function taking:
        x, y        //   the current coordinates (x, y) on the torus
      ) =>          //
    g[              // the surrounding object of g is also used for storage
      x += y * m    // turn x into a key for the current coordinates
    ] ?             // if this cell was already visited:
      !x            //   return 1 if we're back to (0, 0), or 0 otherwise
    :               // else:
      g(            //   first recursive call:
        -~x % m,    //     move to the right
        y,          //     leave y unchanged
        g[x] = 1    //     mark the current cell as visited by setting the flag g[x]
      ) +           //   add the result of
      g(            //   a second recursive call:
        x % m,      //     restore x in [0...m-1]
        -~y % n     //     move up
      ) +           //
      --g[x]        //   clear the flag on the current cell
)(0, 0)             // initial call to g with (x, y) = (0, 0)

Haskell, 88 80 bytes
n#m|let(x!y)a|elem(x,y)a=0^(x+y)|b<-(x,y):a=(mod(x+1)n!y)b+(x!mod(y+1)m)b=0!0$[]

Try it online!
Simple brute force: try all up/right combinations, dropping those which intersect (we keep all positions we've visited in list a) and counting those which eventually hit positition (0,0) again.
The base case of the recursion is when we visit a position a second time (elem(x,y)a). The result is 0^0 = 1 when the position is (0,0) and counts towards the numbers of loops or 0 (0^x, with x non-zero) otherwise and doesn't increase the number of loops.
Edit: -8 bytes thanks to @xnor.

The base cases can be combined into |elem(x,y)a=0^(x+y), and (0!0)[] can be 0!0$[].

Jelly, 44 bytes
×ƝṪ2*Ḥ_2Rḃ€2ċⱮØ½%³¬ẠƲƇịØ.Ṛ,Ø.¤ZÄZ%€ʋ€³ŒQẠ$€S

Try it online!
Works for 4,4, but has complexity \$O({2^m}^n)\$ so won’t scale that well.
This works by finding all possible routes of up to \$mn\$ length, filtering out those that don’t end at 0,0, and then excluding those that pass the same point twice.

Jelly, 54 39 bytes
ḣ2æ.2ị³¤+4
‘Ç;¥¦%³Ç=4ƊÑÇị$?
çⱮØ½S
’Ñ0xÇ

Try it online!
I’ve posted this as a separate answer to my other Jelly one because it’s a completely different method. This is closer in principle to @Arnauld’s answer. It uses a recursive function that works through every possible path until it reaches a point it’s already got to, and then returns the result of a check whether it’s back to the start. I suspect a few more bytes could be shaved off. Now changed to using slice operator. It works well for up to 5x5. The recursion depth should be at most m x n.

CJam (50 chars)
q~]:M:!a{9Yb2/\f{_W=@.+M.%a+_)a#g"WAR"=~}}:R~e_We=

Online demo. This is a program which takes two inputs from stdin.
Finally we have an answer to the question

War, huh, what is it good for?

Dissection
q~]:M        e# Parse input, collect in array, store in M (for moduli)
:!a          e# Zero and wrap in array for starting position (0, 0)
{            e# Define recursive block R
  9Yb2/      e#   Push [[1 0][0 1]], an array of movements
  \f{        e#   For each of those movements, with the current path,
    _W=@.+   e#     Add the movement to the last position in the path
    M.%      e#     Apply the wrapping
    a+       e#     Add to one copy of the path
    _)a#     e#     And find its index in another copy
    g"WAR"=~ e#     Switch on the sign of the index:
             e#       If the sign is -1, position not found, make a recursive call
             e#       If the sign is 0, found at start, push -1 to the stack
             e#       If the sign is 1, we have a self-intersection. We push 10 to
             e#       the stack for no other reason than to make the bad joke above
  }
}:R
~            e# Execute R
e_We=        e# Count the -1s which we pushed as sentinels

Java 8, 120 bytes
n->m->g(n,m,0,0);int g(int n,int m,int k,int l){return(l>>k)%2>0?k<1?1:0:g(n,m,(k+m)%(m*n),l|=1<<k)+g(n,m,k-~k%m-k%m,l);}

Port of @Arnauld's JavaScript answer, and also only works for inputs where \$n*m<32\$.
Try it online.