2022 Developer Survey is open! Take survey.
646 votes
Accepted

Regex that only matches itself

PCRE flavor, 261 289 210 184 127 109 71 53 51 44 40 bytes Yes, it is possible! <^<()(?R){2}>\z|\1\Q^<()(?R){2}>\z|\1\Q> Try it here. (But <...
user avatar
  • 35.8k
253 votes

Is this number a prime?

hello, world!, 13 hello, world!
user avatar
  • 21.8k
169 votes

Is this number a prime?

Hexagony, 29 bytes .?'.).@@/'/.!.>+=(<.!)}($>(<% The readable version of this code is: ...
user avatar
  • 3,341
161 votes

Count of "a"s and "b"s must be equal. Did you get it computer?

Python 3, 32 bytes eval(input().translate(")("*50)) Outputs via exit code: Error for false, no error for True. The string is evaluated as Python code, ...
user avatar
  • 137k
128 votes

Is this even or odd?

ArnoldC, 299 283 bytes ...
user avatar
  • 99.3k
115 votes

Golf all the 16 logic gates with 2 inputs and 1 output!

Dominoes, 122,000 bytes or 72 tiles The byte count is the size of the saved file which is 0.122 MB. Domino computing was the inspiration. I have tested all of ...
user avatar
108 votes

Detect MS Windows

MATLAB, 4 bytes ispc From the documentation: tf = ispc returns logical 1 (true) if the version of MATLAB® software is for ...
user avatar
104 votes

"KNOT" or "NOT"?

Python 3, 457 316 306 bytes ...
user avatar
104 votes
Accepted

Java is to JavaScript as Car is to Carpet

Java/JavaScript Polyglot, 108 107 106 bytes //\u000As->s.matches("(?i)(?!.*javascript)java.*"/* a=>/(?!.*javascript)^java/i.test(a/**/)?"car":"carpet" Run ...
user avatar
95 votes

Check if words are isomorphs

J, 4 bytes -:&= Usage 'THERMODYNAMICS' (-:&=) 'RAMBUNCTIOUSLY' NB. parens are optional 1 Explanation ...
user avatar
  • 20.5k
83 votes
Accepted

Detect MS Windows

Vim, 2 bytes <C-a>1 On Windows, <C-a> (ctrl+a) is mapped by default to ...
user avatar
  • 3,574
81 votes

Magic the Gathering: Friends or Foes?

JavaScript (ES6),  26 23 17 15  14 bytes Takes input as two ASCII codes in currying syntax (a)(b). Returns 4 for ...
user avatar
  • 166k
74 votes

Is this number a prime?

Hexagony, 218 92 58 55 bytes Notice: This answer has been solidly beaten with a side-length 4 solution by Etoplay. ...
user avatar
70 votes

Is this number a prime?

Pyth, 4 bytes }QPQ Prints True or False.
user avatar
  • 38.6k
70 votes

Is My Swipe Pattern Legal?

JavaScript (ES6), 64 bytes Takes input as an array of numbers. Falsy values are 0 or NaN. Truthy values are strictly positive integers. ...
user avatar
  • 166k
65 votes

Is this number a prime?

Retina, 16 bytes ^(?!(..+)\1+$).. Try it online! Let's start with a classic: detecting primes with a regex. Input should be given in unary, using any repeated ...
user avatar
63 votes

Am I being run backwards?

Python 3, no comments or string literals, 106 bytes x=quit y=x.__class__ y.__add__=print y.__pos__=x x+x++x+x x=__sop__.y tnirp=__dda__.y __ssalc__.x=y tixe=x I'...
user avatar
  • 1,548
61 votes

Is it double speak?

Python 3, 24 bytes lambda s:s[::2]==s[1::2] Try it online!
user avatar
  • 6,240
58 votes

Will it halt? (Cops)

Malbolge, 128 bytes, cracked by KBRON111 ...
user avatar
  • 70.5k
56 votes

I'm a palindrome. Are you?

Pyth, 3 bytes _I_ Returns True or False. Try it online! How it works ...
user avatar
  • 206k
55 votes
Accepted

Is my prison secure?

Snails, 13 bytes !(t\P(o\ ),o~ Try it online! Prints 0 for insecure prisons and the size of the input's bounding box for ...
user avatar
52 votes

Is this number a prime?

CJam, 4 bytes qimp CJam has a built-in operator for primality testing.
user avatar
  • 42.8k
52 votes

Will it halt? (Robbers)

Malbolge, Doorknob Try it online (Thanks Dennis!) Input for Windows: F_⌠1234567890 Input on Linux based system using ISO-8559-1: ...
user avatar
  • 581
51 votes

Is this number a prime?

Hexagony, 28 bytes Since Etoplay absolutely trounced me on this question, I felt that I had to outgolf his only other answer. ...
user avatar
  • 11.4k
51 votes

Is this even or odd?

brainfuck, 8 bytes +[,>,]<. Input is in unary. Output is the 1 (truthy) for odd numbers and NUL (falsy) for even numbers. Try it online! How it works We ...
user avatar
  • 206k
50 votes
Accepted

Is it almost-prime?

Sagemath, 2 bytes GF Outputs via exception. Try it online! The Sagemath builtin \$\text{GF}\$ creates a Galois Field of order \$n\$. However, remember that \$\...
user avatar
  • 11.7k
49 votes

Is this number a prime?

Help, WarDoq!, 1 byte P Outputs 1 if the input is prime, 0 otherwise.
user avatar
  • 38.6k

Only top scored, non community-wiki answers of a minimum length are eligible