# Tag Info

628

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 / is shown to be the delimiter on Regex101.) Please refrain from making unnecessary edits (updates) on the Regex101 page. If your edit doesn't actually involve improving, trying or testing this regex, ...

248

hello, world!, 13 hello, world!

163

Hexagony, 29 bytes .?'.).@@/'/.!.>+=(<.!)}($>(<% The readable version of this code is: . ? ' . ) . @ @ / ' / . ! . > + = ( < . ! ) } ($ > ( < % . . . . . . . . Explanation: It test if there is a number from 2 to n-1 who divides n. Initialization: Write n in one memory cell and n-1 in an other: . ? ' . . . . . ....

159

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, replacing parens ( for a and ) for b. Only expressions of the form a^n b^n become well-formed expressions of parentheses like ((())), evaluating to the tuple (). Any mismatched parens give an error, ...

121

ArnoldC, 299 283 bytes IT'S SHOWTIME HEY CHRISTMAS TREE i YOU SET US UP 0 GET YOUR ASS TO MARS i DO IT NOW I WANT TO ASK YOU A BUNCH OF QUESTIONS AND I WANT TO HAVE THEM ANSWERED IMMEDIATELY GET TO THE CHOPPER i HERE IS MY INVITATION i I LET HIM GO 2 ENOUGH TALK TALK TO THE HAND i YOU HAVE BEEN TERMINATED This outputs 1 (which is truthy) for odd input and ...

112

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 these up to symmetry (and beyond!) via a virtual-reality Steam game called Tabletop Simulator. Details I/O Start - This is included for clarity (not counted towards total) and is what 'calls' or '...

108

MATLAB, 4 bytes ispc From the documentation: tf = ispc returns logical 1 (true) if the version of MATLAB® software is for the Microsoft® Windows® platform. Otherwise, it returns logical 0 (false). There are also the functions ismac and isunix. I'll leave it to the reader to figure out what those functions do. Mego kindly asked for diagrams explaining ...

103

Java/JavaScript Polyglot, 108 107 106 bytes //\u000As->s.matches("(?i)(?!.*javascript)java.*"/* a=>/(?!.*javascript)^java/i.test(a/**/)?"car":"carpet" Run as Java //\u000As->s.matches("(?i)(?!.*javascript)java.*"/* a=>/(?!.*javascript)^java/i.test(a/**/)?"car":"carpet" Try it online! Note: don't trust the highlight as it's incorrect. The ...

102

Python 3, 457 316 306 bytes E=enumerate V={'+'} Q=[[(-j,i,k)for i,u in E(open(0))for j,v in E(u)for k in[{v}&V,'join'][u[j:j+2]=='|-']]] while Q: a,b,c,d,*e=A=tuple(x//2for y,x in sorted((y,x)for x,y in E(Q.pop())));e or exit('NOT') if{A}-V:V|={A};Q+=[[c,d,a,b]+e,A,A[2:]+A[:2]][a<c<b<d:][c<a<d<b:] if b==d:Q=[[a,c]+e] exit('KNOT') ...

95

J, 4 bytes -:&= Usage 'THERMODYNAMICS' (-:&=) 'RAMBUNCTIOUSLY' NB. parens are optional 1 Explanation = with 1 argument creates an equality-table comparing the elements of the input and its nub. ='ESTATE' gives the binary matrix = | E S T A T E --+------------ E | 1 0 0 0 0 1 S | 0 1 0 0 0 0 T | 0 0 1 0 1 0 A | 0 0 0 1 0 0 -: with 2 ...

83

Vim, 2 bytes <C-a>1 On Windows, <C-a> (ctrl+a) is mapped by default to Select All. If you type a 1 in select mode in Windows, it replaces the selection with what you typed (1) leaving a 1 in the buffer. On other operating systems, <C-a> by default is mapped to Increment number. Because there's no number to increment, it's a no-op, and ...

81

JavaScript (ES6),  26 23 17 15  14 bytes Takes input as two ASCII codes in currying syntax (a)(b). Returns 4 for friends or 0 for foes. a=>b=>a*b/.6&4 Try it online! How? NB: only the integer quotient of the division by 0.6 is shown below. Combo | a | b | a*b | / 0.6 | AND 4 ------+----+----+------+-------+------ WU | 87 | 85 |...

71

Hexagony, 218 92 58 55 bytes Notice: This answer has been solidly beaten with a side-length 4 solution by Etoplay. )}?}.=(..]=}='.}.}~./%*..&.=&{.<......=|>(<..}!=...&@\[ The first ever non-trivial (i.e. non-linear) Hexagony program! It is based on the same squared-factorial approach as Sp3000's Labyrinth answer. After starting out ...

70

JavaScript (ES6), 64 bytes Takes input as an array of numbers. Falsy values are 0 or NaN. Truthy values are strictly positive integers. a=>a[p=1]*a.every(n=>a[p=a[n&p&p*n%5<0|~(p-=n)==9&&p/2]&&-n]^=p) Test cases let f = a=>a[p=1]*a.every(n=>a[p=a[n&p&p*n%5<0|~(p-=n)==9&&p/2]&&-n]^=p)...

69

Pyth, 4 bytes }QPQ Prints True or False.

63

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 printable character. The test suite includes a conversion from decimal to unary for convenience. A Retina program consisting of a single line treats that line as a regex and prints the number of ...

63

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 never liked how comments and string literals let you "turn off" most of your language's syntax in challenges like this, so I wanted to see how far I could golf things without using either ...

60

Python 3, 24 bytes lambda s:s[::2]==s[1::2] Try it online!

57

Malbolge, 128 bytes, cracked by KBRON111 (=&r:#o=~l4jz7g5vttbrpp^nllZjhhVfddRb`O;:('JYX#VV~jS{Ql>jMKK9IGcFaD_X]\[ZYXWVsN6L4J\[kYEhVBeScba%_M]]~IYG3Eyx5432+rpp-n+l)j'h%B0 Have fun! (Yes, I learned Malbolge just for this. Yes, it took an absurdly long time to finally get working. And yes, it was totally worth it.) Wrapped, so you can see it in its ...

56

Pyth, 3 bytes _I_ Returns True or False. Try it online! How it works _ Reverse the input. _I Invariant-reverse; test if the reversed input is equal to its reverse.

54

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 secure prisons. The idea is to ensure that we can't find a path from a P to an out of bounds cell (~) moving only orthogonally (o) through spaces. The t is a teleport so that regardless where we attempt the match it tries all possible ...

52

CJam, 4 bytes qimp CJam has a built-in operator for primality testing.

52

Malbolge, Doorknob Try it online (Thanks Dennis!) Input for Windows: F_⌠1234567890 Input on Linux based system using ISO-8559-1: F_ô1234567890 The heart of how the Malbolge program worked is that it depended on a behavior of the Malbolge interpreter which causes an infinite loop if it encounters any instruction which is not between 33 and 126. The ...

50

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 $\mathbb{F}_n$ is only a field if $n = p^k$ where $p$ is a prime and $k$ a positive integer. Thus the function throws an exception if and only if its input is not a prime power.

49

Hexagony, 28 bytes Since Etoplay absolutely trounced me on this question, I felt that I had to outgolf his only other answer. ?\.">"!*+{&'=<\%(><.*.'(@>'/ Try it online! I use Wilson's Theorem, like Martin did in his answer: Given n, I output (n-1!)² mod n Here it the program unfolded: ? \ . " > " ! * + { &...

49

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 start by incrementing the current cell with + to be able to enter the while loop [,>,]. In each iteration, , reads a byte from STDIN, > advances to the cell to the right, then , reads ...

48

Help, WarDoq!, 1 byte P Outputs 1 if the input is prime, 0 otherwise.

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