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 <...
253
votes
169
votes
Is this number a prime?
Hexagony, 29 bytes
.?'.).@@/'/.!.>+=(<.!)}($>(<%
The readable version of this code is:
...
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, ...
128
votes
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 ...
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 ...
104
votes
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 ...
95
votes
Check if words are isomorphs
J, 4 bytes
-:&=
Usage
'THERMODYNAMICS' (-:&=) 'RAMBUNCTIOUSLY' NB. parens are optional
1
Explanation
...
83
votes
Accepted
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 ...
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.
...
70
votes
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.
...
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 ...
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'...
61
votes
58
votes
56
votes
I'm a palindrome. Are you?
Pyth, 3 bytes
_I_
Returns True or False.
Try it online!
How it works
...
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 ...
52
votes
Is this number a prime?
CJam, 4 bytes
qimp
CJam has a built-in operator for primality testing.
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: ...
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.
...
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 ...
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 \$\...
49
votes
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
decision-problem × 665code-golf × 646
string × 126
number × 92
math × 79
array × 58
grid × 44
number-theory × 39
primes × 33
integer × 32
graph-theory × 27
sequence × 26
matrix × 26
game × 25
ascii-art × 21
geometry × 19
arithmetic × 18
restricted-source × 16
code-challenge × 15
parsing × 15
subsequence × 15
binary × 14
chess × 14
path-finding × 11
combinatorics × 10