220 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 ...
user avatar
  • 207k
127 votes

Is this even or odd?

ArnoldC, 299 283 bytes ...
user avatar
  • 99.5k
107 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 ...
user avatar
  • 3,195
94 votes

1, 2, Fizz, 4, Buzz

Python 2, 56 bytes i=0;exec"print i%3/2*'Fizz'+i%5/4*'Buzz'or-~i;i+=1;"*100 Try it online!
user avatar
  • 30.9k
91 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. >&...
user avatar
  • 61k
78 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 ...
user avatar
  • 1,429
75 votes

Inverse function

Haskell, 11 bytes f=log pxe=f and in reverse order: f=exp gol=f This works without the "comment" trick. Instead each ...
user avatar
  • 35.3k
74 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 ...
user avatar
  • 7,059
69 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 ...
user avatar
64 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 ...
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 ...
user avatar
  • 88.8k
58 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!
user avatar
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 ...
user avatar
  • 66k
52 votes

1, 2, Fizz, 4, Buzz

Labyrinth, 94 bytes "):_1 \ } 01/3%70.105 " : @ " . " =";_""..:221 + _ "! 5%66.117 _:= " . ="*{"..:221 Sub-100! This was a fun one. Explanation Let'...
user avatar
  • 61k
51 votes

Difference of three input integers

Python 3, 21 bytes lambda*l:sum(l)/2in l If two numbers add to the other, the sum of all three will be double that other number, so half the sum will be an element ...
user avatar
  • 137k
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
  • 207k
50 votes
Accepted

Add two numbers

Jelly, 1 byte + Try it online! Also works in 05AB1E, Actually, APL, Braingolf, ,,, (Commata), dc, Deorst, Factor, Fig, Chocolate, Forth, Halfwit, Implicit, J, ...
user avatar
  • 207k
50 votes

Show me the nearest demon

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

Reciprocal of a number (1/x)

Python 2, 10 bytes 1..__div__ Try it online!
user avatar
  • 207k
47 votes

Abandon all squares, ye who divide me

05AB1E, 2 bytes fP Try it online! How it works ...
user avatar
  • 207k
45 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 ...
user avatar
  • 48.3k
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 ...
user avatar
  • 137k
44 votes
Accepted

Well that's odd... no wait, that's even!

CJam, 18 17 13 bytes Thanks to aditsu for saving 4 bytes. qW:O%eu~"eo"= Try the test suite here. (The test suite is too long for the permalink. Just copy them ...
user avatar
43 votes

Yes, of course I'm an adult!

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

Calculate the square of an integer with restrictions

CJam, puts on his glasses q~33c (*_*) (*_")>⌐■-■ (⌐■_■) "]sG>4%,) Input via STDIN Try the code here Note that ...
user avatar
  • 26.3k
42 votes

Inverse function

APL, 3 bytes *⊣⍟ This is a function train. Monadic * returns e^x, monadic ...
user avatar
  • 31.1k
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 ...
user avatar
  • 207k
41 votes

Divisibility test

Jelly, 1 byte This took me hours to golf. Try it online!
user avatar
  • 57.3k
41 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 ...
user avatar
  • 137k

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