208

Jelly, 12 bytes N+N “(ẹ+)‘FQṖṪỌv Try it online! N×N ““((ẹẹ++))‘‘FFQQṖṖṪṪỌỌvv Try it online! N^N “““(((ẹẹẹ+++)))‘‘‘FFFQQQṖṖṖṪṪṪỌỌỌvvv Try it online! How it works Jelly has several different types of string literals; all of them start with a “. If the literal contains more than one “, a string array is returned, and “ separates the strings from each ...


125

Fortran IV: 2=0 After this every constant 2 in the program is zero. Trust me, I have done this (ok, 25 years ago)


119

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 ...


100

This seems to work: #define x 2|0 Basically, the expression is expanded to (2|0 == 2|(0+2)). It is a good example of why one should use parentheses when defining macros.


89

><>, 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. ><> is a 2D language, so we can make use of the fact that code semantics are mostly unchanged if we execute instructions downwards — the extra empty lines that ensue are just no-ops. The ...


86

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 I neither had the Hexagony colorer nor the EsotericIDE to check my solution. I got several aspects of the specification wrong, so I produced a few wrong “...


79

Brainfuck x This does of course stretch "evaluate to true" a bit, because in Brainfuck nothing actually evaluates to anything – you only manipulate a tape. But if you now append your expression x (x == x+2) the program is equivalent to + (because everything but <>+-[],. is a comment). Which does nothing but increment the value where we are now. ...


77

Python 2, 56 i=0;exec"print i%3/2*'Fizz'+i%5/4*'Buzz'or-~i;i+=1;"*100


75

Haskell, 11 bytes f=log pxe=f and in reverse order: f=exp gol=f This works without the "comment" trick. Instead each version defines an additional, but unused function (pxe/ gol).


71

main() { double x=1.0/0.0; printf("%d",x==x+2); } Outputs 1. Link: http://ideone.com/dL6A5


70

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 making you input the numbers into the program itself. (It's somewhat justifiable because quite a few maps, like Lorgon111's Minecraft Bingo, require you to copy ...


68

Mathematica, 15 bytes Byte count assumes Windows ANSI encoding (CP-1252). 6±9=42 ±n__:=1n Defines a binary operator ± which solves the problem. We simply define 6±9=42 as a special case which takes precedence and then add a fallback definition which makes ± equal to multiplication. The latter uses a fairly interesting golfing trick. The reason this works ...


65

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 some improvements from miles and Martin (see comments). miles' is also 46 bytes, but faster: {1,4^8}.{Tr@#+1,Tr[Accumulate@#+1]}~Mod~65521&


63

Mathematica, 10 bytes Fibonorial Another Mathematica built-in soundly beaten by a golfing language without the built-in.


58

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 strings, hence the +1. (({})[((((()()()()())){}{})){}{}]){((<{}>))}{}({}<{({}[((((()()()){}())()){}{}){}]<>)<>}<>{({}<>[()()])<>}{}([]<{({}<>[()()])&...


58

Haskell, 14 bytes 6&9=42 a&b=a*b Try it online!


56

F# let (==) _ _ = true let x = 0 x == (x + 2) //true


56

Jelly, 7 bytes SH_÷@HP Try it online! Explanation Let’s read this chain: The implicit argument is a list [a, b, c]. First we read S. This takes the sum: a + b + c. Then, we read H. This halves it: (a + b + c)/2. (This is s.) Then, we read a dyad _ (subtract), followed by another dyad. This is a hook: it lacks a right argument, so it receives the ...


52

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 of the list. Python 3 is needed to avoid floor-division, unless the numbers are given like 3.0 rather than 3.


52

Regex (ECMAScript+(?*)), 1169 929 887 853 849 bytes Regex was never designed to do mathematics. It has no concept of arithmetic. However, when input is taken in the form of bijective unary, as a sequence of identical characters in which the length represents a natural number, it is possible to do a wide range of operations, building up from the simple ...


51

Python 2, 28 bytes lambda n:'6'*len(`-~n*3/11`)


50

C int main() { float x = 1e10; printf("%d\n", x == x + 2); } Note: may not work if FLT_EVAL_METHOD != 0 (see comments below).


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 ...


47

Python 2, 10 bytes 1..__div__ Try it online!


46

Labyrinth, 94 bytes "):_1 \ } 01/3%70.105 " : @ " . " =";_""..:221 + _ "! 5%66.117 _:= " . ="*{"..:221 Sub-100! This was a fun one. Explanation Let's start with a brief primer on Labyrinth – feel free to skip this if you're already familiar with the basics: Labyrinth has two stacks – a main stack and an auxiliary stack. Both stacks have an ...


45

05AB1E, 2 bytes fP Try it online! How it works f Implicitly take input and compute the integer's unique prime factors. P Take the product.


44

APL, 3 bytes *⊣⍟ This is a function train. Monadic * returns e^x, monadic ⍟ returns ln(x). ⊣ is a dyadic function that returns its left argument. Thus, *⊣⍟ is equivalent to just *, and the reverse ⍟⊣* is equivalent to just ⍟.


44

Python 2.7, 34 bytes lambda x:max(x,[18,1.4]['.'in`x`])


44

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 equivalent to the problem condition a-b in symrange(a,b)? Note that x in symrange(a,b) is equivalent to 0 in symrange(a-x,b-x). Applying this to x=a-b gives 0 in symrange(b,2*b-a). The value 0 is included in the interval unless it ...


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