Skip to main content
Share Your Experience: Take the 2024 Developer Survey
224 votes

Hyperprogramming: N+N, N×N, N^N all in one

Jelly, 12 bytes N+N “(ẹ+)‘FQṖṪỌv Try it online! N×N ““((ẹẹ++))‘‘FFQQṖṖṪṪỌỌvv Try it online! N^N ...
Dennis's user avatar
  • 210k
131 votes

Is this even or odd?

ArnoldC, 299 283 bytes ...
Luis Mendo's user avatar
  • 105k
111 votes

1, 2, Fizz, 4, Buzz

Hexagony, 91 bytes Thanks for the bounty :) Wow, I would never have imagined I could beat Martin’s Hexagony solution. But—who would have thunk it—I got it done. After several days of failure because ...
M L's user avatar
  • 3,265
93 votes

Hyperprogramming: N+N, N×N, N^N all in one

><>, 41 bytes \< 1:: : &&* + i*n n c& %: 4l 0( .i n} &? Try it online: N+N, N*N, N^N. Assumes that the STDIN input is exactly one char. >&...
Sp3000's user avatar
  • 61.8k
81 votes

Add two numbers

Minecraft 1.10, 221 characters (non-competing) See, this is what we have to deal with when we make Minecraft maps. Aside: There's no way to take a string input in Minecraft, so I'm cheating a bit by ...
quat's user avatar
  • 1,499
79 votes

Shift right by half a bit

Regex (ECMAScript+(?*)), 1169 929 887 853 849 708 bytes -141 bytes by using the second form of shortened division, where \$A^2 > C\$ Regex was never designed to ...
Deadcode's user avatar
  • 11.6k
68 votes

What do you get when you multiply 6 by 9? (42)

Mathematica, 15 bytes Byte count assumes Windows ANSI encoding (CP-1252). 6±9=42 ±n__:=1n Defines a binary operator ± which ...
Martin Ender's user avatar
66 votes

Compute the Adler-32 checksum

Mathematica, 46 bytes {1,4^8}.Fold[##+{0,#&@@#}&,{1,0},#]~Mod~65521& An anonymous function that takes an integer array and returns the Adler-32, with ...
Mark Adler's user avatar
59 votes

What do you get when you multiply 6 by 9? (42)

Haskell, 14 bytes 6&9=42 a&b=a*b Try it online!
Anders Kaseorg's user avatar
58 votes

Reciprocal of a number (1/x)

Brain-Flak, 772 536 530 482 480 + 1 = 481 bytes Since Brain-Flak does not support floating point numbers I had to use the -c flag in order input and output with ...
Wheat Wizard's user avatar
  • 98.8k
56 votes

Evaluate the aspect ratio of a triangle

Jelly, 7 bytes SH_÷@HP Try it online! Explanation Let’s read this chain: The implicit argument is a list [a, b, c]. First ...
lynn's user avatar
  • 68.7k
55 votes
Accepted

Add two numbers

Jelly, 1 byte + Try it online! Also works in 05AB1E, Actually, APL, BQN, Brachylog, Braingolf, Chocolate, ,,, (Commata), dc, Deorst, Factor, Fig**, Forth, Halfwit*,...
Dennis's user avatar
  • 210k
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 ...
Dennis's user avatar
  • 210k
50 votes

Show me the nearest demon

Python 2, 28 bytes lambda n:'6'*len(`-~n*3/11`)
orlp's user avatar
  • 39.1k
48 votes

Reciprocal of a number (1/x)

Python 2, 10 bytes 1..__div__ Try it online!
Dennis's user avatar
  • 210k
46 votes

Add two numbers

Binary lambda calculus, 4.125 bytes Input and output as Church numerals. 00000000 01011111 01100101 11101101 0 In lambda calculus, it is λm. λn. λf. λx. m f (n ...
Leaky Nun's user avatar
  • 49.7k
46 votes

Abandon all squares, ye who divide me

05AB1E, 2 bytes fP Try it online! How it works ...
Dennis's user avatar
  • 210k
45 votes

If A-B be in A-B A else B eh?

Python, 27 bytes lambda a,b:[a,b][2*b*b>a*b] Try it online! An arithmetic formula. Why is the negation of 2*b*b>a*b ...
xnor's user avatar
  • 145k
44 votes

Moving modest minimum

Python 2, 41 bytes lambda l:[sorted(l)[x==min(l)]for x in l] Try it online! For each element x we check whether ...
xnor's user avatar
  • 145k
43 votes

Yes, of course I'm an adult!

Python 2.7, 34 bytes lambda x:max(x,[18,1.4]['.'in`x`])
lynn's user avatar
  • 68.7k
43 votes

Random point on a sphere

Wolfram Language (Mathematica), 20 bytes RandomPoint@Sphere[] Try it online! Does exactly what it says on the tin.
att's user avatar
  • 20.6k
42 votes

Addition in base -1+i

Python 2, 98 97 91 84 bytes s=input();L=1 for _ in`s`*8:s+=1098*int(str(s).translate('0011'*64));L*=10 print s%L This does I/O in decimal. The integers have to ...
Dennis's user avatar
  • 210k
42 votes

Is it a sum-free set?

Python 2, 41 bytes lambda s:s==s-{a+b for a in s for b in s} s should be a Python set. Fun fact: ...
feersum's user avatar
  • 31.4k
41 votes

Divisibility test

Jelly, 1 byte This took me hours to golf. Try it online!
DJMcMayhem's user avatar
  • 59.2k
41 votes

Notcalc (Calculate the wrong answer)

RProgN, 4 3 1 Byte Crossed out 4 is still 4 ;( E The most simple of solutions, compares if A and B are equal. Pushes true, which RProgN sees as 1, if they are the ...
ATaco's user avatar
  • 10.8k
41 votes

Is this even or odd?

Mathematica, 4 bytes OddQ Gives True for odd inputs and False for even inputs, who knew? ...
Martin Ender's user avatar
40 votes
Accepted

Greatest Common Divisor

Retina, 16 ^(.+)\1* \1+$ $1 This doesn't use Euclid's algorithm at all - instead it finds the GCD using regex matching groups. Try it online. - This example ...
Digital Trauma's user avatar
40 votes

Output a string's cumulative slope

Python, 29 bytes lambda s:ord(s[-1])-ord(s[0]) The sum of the differences forms a telescopic series, so most summands cancel out and (s1 - s0) + (s2 - s1) + &...
Dennis's user avatar
  • 210k
38 votes

Reciprocal of a number (1/x)

Retina, 99 91 bytes 1`\.|$ 8$*; +`;(;*)(\d) $2$1 \d+ $*1,10000000$* (1+),(\1)+1* $#2 +`(\d)(;+); $2$1 1`; . ; 0 Try it online! Woohoo, sub-100! This is ...
Martin Ender's user avatar

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