262
votes
170
votes
Is this number a prime?
Hexagony, 29 bytes
.?'.).@@/'/.!.>+=(<.!)}($>(<%
The readable version of this code is:
...
165
votes
Count of "a"s and "b"s must be equal. Did you get it computer?
Python 3, 32 bytes
eval(input().translate(")("*50))
Try it online!
Outputs via exit code: Error for false, no error for True.
The string is evaluated as ...
131
votes
121
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 ...
113
votes
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 ...
107
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 ...
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 ...
76
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.
...
73
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've ...
72
votes
71
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 ...
62
votes
58
votes
57
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 ...
53
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.
...
52
votes
Is this number a prime?
CJam, 4 bytes
qimp
CJam has a built-in operator for primality testing.
52
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 ...
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
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 \$\...
50
votes
50
votes
I'm a palindrome. Are you?
Python, 39 bytes
lambda s:s[::-1]==s#s==]1-::[s:s adbmal
Try it online!
Boring, but if there is shorter in Python it will be impressive.
49
votes
Golf all the 16 logic gates with 2 inputs and 1 output!
Hexagony, 89 bytes
Thanks to FryAmTheEggman for some necessary inspiration for the XOR solution.
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
decision-problem × 731code-golf × 710
string × 139
number × 95
math × 82
array × 65
grid × 45
number-theory × 40
integer × 35
primes × 34
graph-theory × 32
game × 28
matrix × 28
sequence × 26
ascii-art × 24
geometry × 20
parsing × 19
chess × 19
arithmetic × 18
restricted-source × 17
code-challenge × 15
subsequence × 15
binary × 14
palindrome × 12
balanced-string × 12