# Can you give me half? (No digits) [closed]

The task is to provide code that evaluates to 0.5 numerically, i.e. the output must be recognized by your chosen language as a numeric value (Number, float, double, etc), not as a string. The catch, the characters 0 through to 9 cannot be used.

PLEASE NOTE: This IS NOT a golfing challenge, this is a popularity contest, so creative answers are encouraged. The more obscure and convoluted answers are also encouraged.

One example that fits the brief would be the following:

((++[[]][[~~""]]<<++[[]][[~~""]]))**((--[[]][[~~""]])) which works out to 0.5 in JavaScript.

A bounty of 150 will be awarded as an added incentive for the most voted creative answer. Good luck!

Any questions, feel free to ask.

• TBH, @AviFS it surprises me that people forget there are more different categories of challenges than just code golf... I want my fellow golfers to embrace their inner goofball and provide more esoteric and convoluted answers based on their language of choice... And there was an objective, output half without numeric digits... ;) – Eliseo D'Annunzio Jun 21 at 9:22
• It's not that the challenge is not code golf, it's that it's the blandest, most generic kind of popularity contest -- a trivial task where we're asked to be creative with "obscure and convoluted answers". At that point all pop cons might as be merged into one challenge that says "write whatever you want, upvote every answer". – xnor Jun 21 at 10:08
• @WheatWizard I haven't seen a challenge get 40 answers the day-of in a long time. I wonder if we're not missing pretty clear signs that this is the way to ramp up engagement. It's certainly more inviting, and the barrier to entry is less rigid. Perhaps we're elitists in our ivory towers to be demanding objectivity & strictly defined winners everywhere we go. – AviFS Jun 21 at 10:23
• @AviFS 40 answers in a day is not a good sign. In fact it is a very bad sign. – Wheat Wizard Jun 21 at 10:26
• Code trolling also caused a massive spike of activity back in 2014 @AviFS, that doesn't mean they were quality questions. More answers doesn't not equal a quality question. Pop-cons have been a controversial topic for years, but it is possible to run a pop-con that isn't just "Do this but creatively" – caird coinheringaahing Jun 21 at 10:28

# Jelly, 177 bytes

Never gonna give you up,
Never gonna let you down,
Never gonna run around and desert you.
Never gonna make you cry,
Never gonna say goodbye,
Never gonna tell a lie and hurt you.

Try it online!

Explanation thanks to caird coinheringaahing.

Never gonna give you up,                Helper Link; never called
Never gonna let you down,               Helper Link; never called
Never gonna run around and desert you.  Helper Link; never called
Never gonna make you cry,               Helper Link; never called
Never gonna say goodbye,                Helper Link; never called
Never gonna tell a lie and hurt you.    Main Link
Never gonna tell a lie and hurt yo      Random stuff that doesn't matter
u     Undefined so everything before it gets trashed
.    0.5

... yeah. Not that exciting when you see how it works.

• Props for the Rick-roll... Well played... – Eliseo D'Annunzio Jun 20 at 23:55
• Got to love undefined behaviour and chain breaking... – caird coinheringaahing Jun 21 at 0:17
• @hyper-neutrino The u at the end of you is undefined, which breaks the chain and ignores everything before it. Therefore, the only code that's executed is . – caird coinheringaahing Jun 21 at 1:36
• @cairdcoinheringaahing well that explains why the h in hurt stopped d from causing issues with trying to divmod by 0... I thought I was losing my mind and forgetting how monadic 2,2 chaining worked lmao. – hyper-neutrino Jun 21 at 1:56
• Lyxal is going to be jealous of you.... – wasif Jun 21 at 2:00

# Perl 5

Once upon a midnight dreary, while "I pondered", !weak and weary;
Over many a quaint and curious volume of for@gotten, @lore;
While I nodded, nearly napping, until /|there came a tapping|/;
As if someone ? ${!gently} = "rapping" ^ "rapOing at": my$chamber, $door; "Tis some visitor", I-muttered, "tapping at my chamber door"; print unpack f,${!this} and nothing x more

Try it online!

Ah, distinctly I remember it was in the bleak December; And each separate dying ember wrought its ghost upon the floor.

### Explanation / Spoiler:

Perl has a feature called 'barewords', which allows alphanumeric sequences to automatically be parsed as strings. This means that something like

foo bar baz

Will parse as valid Perl, but give a runtime error. However, if we can avoid Perl evaluating it, we can avoid the runtime error. The following program will run without any error:

foo bar baz while 0

Now let's have a look line by line:

Once upon a midnight dreary, while "I pondered", !weak and weary;

"I pondered", !weak and weary evaluates essentially to ("I pondered", false) which is falsy so the stuff on the left hand side of the while loop does not get evaluated.

Over many a quaint and curious volume of for@gotten, @lore;

This is a for loop over the lists @gotten and @lore, which are empty, so the left hand side doesn't get evaluated.

While I nodded, nearly napping, until /|there came a tapping|/;

This is an until loop, where /|there came a tapping|/ is a regex matching against $_. Even though$_ is empty, the leading | matches against the empty string so the match becomes truthy so we don't evaluate the left hand side.

As if someone ? ${!gently} = "rapping" ^ "rapOing at": my$chamber, $door; if is a keyword here. someone is a bareword which is truthy, so we evaluate${!gently} = "rapping" ^ "rapOing at", which sets ${''} to the string "\0\0\0?\0\0\0 at". my$chamber, $door parses as a function call which is never evaluated, so there's no error. "Tis some visitor", I-muttered, "tapping at my chamber door"; I and muttered are both barewords. print unpack f,${!this} and nothing x more

This parses as (print unpack f, ${!this}) and nothing x more.${!this} is ${''}, which is our string from earlier. unpack f is a function that unpacks a single 32 bit float from a packed 4 byte representation. The first 4 bytes of${''} are "\0\0\0?", which happens to be a valid representation of 0.5. The rest of the string is ignored.

Since (print unpack f, \${!this}) is truthy, the right hand side of the and is evaluated. x is the string repeat operator, and nothing and more are both barewords, so there's no error generated.

• Wait, how does Perl 5 know how to parse the code from the rest of Edgar Allen Poe's prose? – Eliseo D'Annunzio Jun 21 at 0:47
• @EliseoD'Annunzio as a hint, have a look at the Perl keywords that are highlighted in blue. There's multiple kinds of syntax abuse here. – Sisyphus Jun 21 at 1:46
• I see those, but I'm not familiar with Perl's ability to abuse syntax. Any chance you can explain. This is something I've never heard of before, so I'm hoping to understand this more. – Eliseo D'Annunzio Jun 21 at 1:48
• @EliseoD'Annunzio I have edited in an explanation. – Sisyphus Jun 21 at 2:41
• That is absolutely brilliant... – Eliseo D'Annunzio Jun 21 at 2:45

# Raku, 5 bytes

π/τ

Try it online!

The constant Pi divided by Tau is, of course, 1/2. An alternative without the pesky unicode is to spell it out like pi/tau.

# Vyxal, 122 bytes

H   H  AAAAA  L      FFFFF
H   H  A   A  L      F
HHHHH  AAAAA  L      FFFFF
H   H  A   A  L      F
H   H  A   A  LLLLL  ½

Try it Online!

You asked for half, so I've given you half in more ways than 1 (/2).

This relies on the fact that most things here are NOPS and that getting the length of a number works.

The real work comes when we get to the Ls in the bottom row: the first L is passed, 0, which has length 1. The next 4 Ls all return 1 because the length of 1 is 1. The ½ then divides that 1 by 2.

# Python 3, 117 bytes

Try it online!

(lambda n:round(sum(__import__('random').random()for _ in range(n))/n,ord('B')-ord('A')))(ord('~')*ord('~')*ord('~'))

This takes the average of a bunch of random numbers in the range 0-1 then rounds it. There is a very small chance this does not evaluate to 0.5

• Love it. It's rare to see non-deterministic solutions on challenges like this. – Recursive Co. Jun 21 at 5:23

# Jelly, 1 byte

.

Try it online!

I know it isn't golf, but why be creative when the tools are provided for you?

. is a decimal literal in Jelly. When the values before the . is omitted, it defaults to 0 and after it defaults to 5. Therefore . is just 0.5

• I feel like you just put a full stop to this challenge. – Adám Jun 20 at 23:43
• Polyglot with Vyxal: Try it Online! – lyxal Jun 20 at 23:58

# BQN

A.k.a "the worm".

=⊸÷⟜≠⌾‿⌾

Try it!

Produces a 2-element list consisting of two built-ins (), then divides the rank (1) by the length (2).

Various superfluous parentheses and no-ops can be added for style:

(=÷≠)(⌾‿⌾)
=(⊸)(÷⟜≠)(⌾‿⌾)
⊣(=)(⊸)(÷⟜≠)(⌾‿⌾)
(=)(⊸)(÷)(⟜)(≠)(⌾‿⌾)

Or how about the chicken and the owl:

(≡÷≠)⊢⟨˙⋄˙⟩
(≡÷≠)⊢⟨⌾,⌾⟩

# C (GCC, MIPS)

// A very mysterious function
float mystery()
{
// A very mysterious string
char whaaaaaa['?'] = "?";
// A very mysterious cast
return *(float *)whaaaaaa;
}

If you want to test it on a non-based x86 or ARM CPU, try htonl('?').

#### Explanation

The reason I choose MIPS is because I wanted it to be big endian.
The convenient thing about 0.5f is it is represented as 0x3f000000. 0x3f is ? in ASCII.
The string will be stored as 3f 00 00 00 ... in memory, and dereferencing it on a big endian machine will conveniently result in 0x3f000000.

• Isn't MIPS bi-endian? This should work on any big-endian machine, right? – Oskar Skog Jun 21 at 9:15
• yes, the important thing is big endian. MIPS32 is usually big endian. – EasyasPi Jun 21 at 15:30

# Wolfram Language (Mathematica), 75 bytes

ElementData["Hydrogen","AtomicNumber"]/ElementData["Helium","AtomicNumber"]

The atomic numbers of hydrogen and helium are exactly 1 and 2, respectively. Atomic masses aren't exact (except for carbon-12's, by defintion, when expressed in daltons), but atomic numbers are, since they're simply the number of protons in the atoms of the element.

[Not sure how to get this working in TIO, or if solutions requring a server connection are allowed in popularity contests.]

• Loving this, the BSc from my university years took notice of this one! – Eliseo D'Annunzio Jun 21 at 2:42
• @EliseoD'Annunzio I find calling the Wolfram server from within a Mathematica notebook has become the easiest way to get basic data on elements and compounds. But in that case, unless I need something very specific, I'll prepend an = so I can use Wolfram Alpha's natural language input, to avoid the heavy syntax. E.g.: =molecular weight glucose instead of ChemicalData["DPlusGlucose", "MolarMass"] (or, even worse, MoleculeValue[Entity["Chemical", "DPlusGlucose"], {"MolarMass"}]). – theorist Jun 21 at 8:19

# JavaScript, 67 bytes

Abuses the fact that undefined is a valid identifier in JS.

undefined=>(undefined=>undefined/(undefined+undefined))(!undefined)

Try it online!

• What's the mechanism behind this? – James Hyde Jun 21 at 13:35
• @JamesHyde My (possibly incorrect or incomplete) understanding: It may be more readable as f = a=>((b=>b/(b+b))(!a)). When you call a function in JS with fewer arguments than declared, the rest are set to undefined, so when we call f(), a is set to undefined, so we have ((b=>b/(b+b))(!undefined)). !undefined is true in JS (because undefined is falsey(?)), so we have (true/(true+true)). doing arithmetic to true makes it behave as 1, so we have (1/(1+1)) == (1/2) == 0.5 – pizzapants184 Jun 22 at 0:03

# Python 3, 420 bytes

from math import*
H=lambda n:int(n,int(sqrt(ord('Ā'))))
o=ord
print(round(sin(H('d')*pi/(H('d')-H('a')))*cos(H('d')*pi/(o('G')-ord('A')))-sin(H('b')*pi/(o('G')-ord('A')))*cos(-(H('f')-H('a'))*pi/(H('d')-H('a'))))/(round((sin(pi/(o('h')-o('a')))*(pi/(o('h')-o('a'))))+(sin((H('f')-H('a'))*pi/H('e'))*(H('f')-H('a'))*pi/H('e'))+(sin(sqrt(o('@'))*pi/((o('h')-ord('a'))))**(H('d')-H('a')))+(sin(sqrt(o('Q'))*pi/H('e'))))))#

Try it online!

Directly from my math book. Solving it by bare hands was a big pain. But writing this answer from mobile was fun. oh plus got a nice byte count.

$$\frac{\sin \frac{13\pi}{3}\cos \frac{13\pi}{6}-\sin \frac{11\pi}{6}\cos \left(-\frac{5\pi}{3}\right)}{ \sin^2\frac{7\pi}{3}+\sin^2\frac{5\pi}{14}+\sin^2\frac{8\pi}{7}+\sin^2\frac{9\pi}{4}}=0.5$$

# Jelly, "HALF OF ONE"

Yes, Jelly can output half of one with just . but did you know there is a secret verbose mode with a certain lexicon of reversed English?

ENO FO FLAH

Try it online!

### How?

OK, so I lied.

ENO FO FLAH - Link: no arguments            (implicit 0)
E           - (implicit [0]) all equal?            -> 1
N          - negate                               -> -1
O         - ordinal (a no-op with numeric input) -> -1
F       - flatten                              -> [-1]
O      - ordinal (vectorisesl again a no-op)  -> [-1]
F    - flatten                              -> [-1]
L   - length                               -> 1
A  - absoulte value                       -> 1
H - halve                                -> 0.5
• Wow, I really like this one! – LorenDB Jun 21 at 18:36

# Jelly, 10 bytes

Ænɓ,ÆṛUÆrḢ

Try it online!

We construct the polynomial $$\4x^2 - 4x + 1\$$, then solve it as equal to $$\0\$$, giving $$\x = \frac 1 2\$$

## How it works

Ænɓ,ÆṛUÆrḢ - Main link. Takes no arguments
Æn         - Next prime after zero; 2
ɓ        - New dyadic chain f(2,2):
,       - Pair; [2,2]
Æṛ     - Construct the polynomial with the roots 2, 2: [4,-4,1]
U    - Reverse; [1,-4,4]
Ær  - Get the roots of this polynomial; [0.5, 0.5]
Ḣ - Get the first element

Why use 1 byte when lot byte do trick?

• Loving it, nice and convoluted! – Eliseo D'Annunzio Jun 21 at 0:12

# Ruby

Line number trickery.

p __LINE__ -
__LINE__ **-
__LINE__ *
__LINE__ .
to_f

Try it online!

### Explanation

__LINE__ is a global constant which stores the current line number. As such, the program can be rewritten into one line as: p 1-2**-3*4.to_f, which just so happens to evaluate to 0.5. The .to_f is needed to cast the result to a float (otherwise (1/2) is printed).

• Bravo! Love this train of thought! – Eliseo D'Annunzio Jun 21 at 9:40

# Dyalog APL

÷∊⊆⊂∪⊃⊢⊣⊥⍨⍲⍀∨\⍱⌿∧/↑↓⍎⍕⍋⍒⍸⍴⍪,⍉⊖⌽⌹|⌈⌊*¨⍟⍤○⍥!×+~-≢⍬⍝

EDIT: I've updated the picture & text, but not the link nor the explanation.

Try it online!

Uses as many unique primitives as I had the patience to cram in. Andvmany thanks to Adám for giving me a bunch more to cram in! It looks cooler with a proper APL font:

(That is, as many primitives as I could use in a linear chain of execution without parentheses. I'm sure you can use every single one if you allow parentheses, as that opens up the dyadic functions.)

### Explanation

÷        Inverse            ->  1/2
↑        Mix                ->  2
↓        Split              ->  2
⊃        First              ->  2
∪        Unique             ->  2
⊂        Enclose            ->  2
⊣        Same (left)        ->  2
⊢        Same (right)       ->  2
∨\       Scan with GCD      ->  2
∧/       Reduce with LCM    ->  2
⍸        Where              ->  [1,2]
⍴        Shape              ->  [1,1]
⍪        Table               ->  3
,        Ravel              ->  3
⍉        Transpose          ->  3
⊖        Horizontal flip    ->  3
⌽        Vertical flip      ->  3
|        Absolute value     ->  3
⌈        Ceiling            ->  3
⌊        Floor              ->  3
*        Exponent           ->  3.14159
¨        Map                ->  1.14472
⍟        Natural logarithm  ->  1.14472
⍤        Atop               ->  3.14159
○        Pi times           ->  3.14159
⍥        Over               ->  1
!        Factorial          ->  1
×        Direction          ->  1
+⍨       Add to itself      ->  2
~        NOT                ->  1
-        Negate             ->  0
∊        Enlist             ->  0
≢        Length             ->  0
⍬        Empty list         ->  []
• can be #∩⍬ – Adám Jun 21 at 12:37
• can be ⊃⍣= – Adám Jun 21 at 12:40
• So many symbols ⍤ – DLosc Jun 21 at 20:09

# Pyth, 4 bytes

cTyT

Try it here!

Divides ten by twice ten.

# C (gcc), 30 bytes

float f(){float x=' ';x/='@';}

Try it online!

Because $$\x\$$ is a float the characters ' ' ($$\32\$$) and '@' ($$\64\$$) get converted to floating point numbers. Then the GCC trick of returning the last calculation is used to return $$\\frac{1}{2}\$$.

# Perl 6

say ½

Try it online!

Doesn't need explanation, does it?

# APL (Dyalog Extended)

#÷⍥≢⍬⍬

Try it online!

Divides the length of a reference to the root namespace (1) by the length of [[],[]] (2).

• I'm sure you were going for creative, rather than golfy, but here it is golfed! – AviFS Jun 21 at 7:07

# APL (dzaima/APL)

⎕←⌈∘○⍢÷*≢~≢⍬

Try it online!

the empty list; []

its length; 0

~ logical NOT; 1

*e to the power of that; 2.71828…

⍢÷ while inverted; 0.36787…

∘○ multiply by π; 1.15572…

round up; 2

Then we "un-invert"; 0.5

# Desmos, 14 7 bytes

e/(e+e)

Try it on Desmos!

# JSFuck, 2443 bytes

[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]][([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]((!![]+[])[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+([][[]]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+!+[]]+(+[![]]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]+(+(!+[]+!+[]+!+[]+[+!+[]]))[(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([]+[])[([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]][([][[]]+[])[+!+[]]+(![]+[])[+!+[]]+((+[])[([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[+!+[]+[+!+[]]]+(!![]+[])[!+[]+!+[]+!+[]]]](!+[]+!+[]+!+[]+[!+[]+!+[]])+(![]+[])[+!+[]]+(![]+[])[!+[]+!+[]])()((![]+[])[+!+[]]+(![]+[])[!+[]+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]+(!![]+[])[+[]]+([][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]]+[])[+!+[]+[!+[]+!+[]+!+[]]]+[+[]]+(+(+!+[]+[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+[!+[]+!+[]]+[+[]])+[])[+!+[]]+[!+[]+!+[]+!+[]+!+[]+!+[]]+([+[]]+![]+[][(![]+[])[+[]]+(![]+[])[!+[]+!+[]]+(![]+[])[+!+[]]+(!![]+[])[+[]]])[!+[]+!+[]+[+[]]])

Quite big

# Python 3, 71 bytes

from http import HTTPStatus
• # 200/400 number spotted /s – EasyasPi Jun 21 at 21:08
• Another creative solution! Excellent!! – Nate T Jun 21 at 23:06

# J, 11 bytes

_"_-:@-:_"_

Try it online!

• In J, -:, as a dyadic verb, means "do the two things match?" and, as a monadic verb, means "half".
• _ is the literal symbol for infinity. Adding "_ turns it into a verb of infinite rank that always returns the value infinity. This is required syntactically for the right version of _"_, and we add it to the left one for symmetry.
• Now, for any argument, the verb checks if _ is equal to _, and always returns 1. And half of 1 is 0.5.
• Though of course %#_ _ would do. – Adám Jun 21 at 0:01
• Sure, but not as pretty :) – Jonah Jun 21 at 0:01

# APL (Dyalog Unicode)

(+-÷)⍨⍣(×≡#⍬)≢⍬

Try it online!

the empty list; []

its length; 0

() compute:

#⍬ a literal; [reference-to-root-namespace,[]]

the depth (nestedness) of that; -1 (maximum depth is 1, but negative value indicates raggedness)

apply the following tacit function that many times (i.e. find an argument to the following function such that the result is 0 (from the length of the empty list above)

()⍨ apply this function with its sole argument as both left and right argument:

+-÷ the sum minus the ratio

Effectively solves $$\x+x-x÷x=0\$$ or $$\2x-1=0\$$ which gives $$\x=1÷2=0.5\$$.

# Wolfram Language (Mathematica), 35/12 bytes

Limit[(-I*I-Cos[x])/(x*x),x->I/∞]

The starting point for this is the following limit:

$$\lim_{x\rightarrow 0}\frac{1-\cos(x)}{x^2} = \frac{1}{2}$$

To eliminate the numbers, I then replaced 0 with ⅈ/∞, 1 with –ⅈ^2, and x^2 with x*x:

$$\lim_{x\rightarrow i/\infty}\frac{-i^2-\cos(x)}{x*x} = \frac{1}{2}$$

Or, less fancy:

-I*I/Floor@E

$$\frac{-i*i}{\lfloor e \rfloor} = \frac{1}{\lfloor \approx 2.718 \rfloor} =\frac{1}{2}$$

[Wasn't sure if the etiquette is to combine this with my previous answer or post separately but, following Caird's example, I did the latter.]

• I think this is my favorite. Just straight math. – Alec Jun 21 at 16:05

# Ly, 23 bytes

<<'<::+/u':':'u/+::<'<<

Try it online!

A reversible one just for fun...

<<                       # Shift stack left twice
'<                     # Push "<" on the stack
::                   # Duplicate top of stack twice
+/                 # Add then divide to get 0.5
u                # Print as a number
# The rest of the code winds up being ignored...  The code just
# has to be valid and not generate output.
':':'u          # Push "::u" onto the stack
/+::      # Divide, add, then duplicate top of stack twice
<     # Shift stack left
'<   # Push "<" on the stack
<  # Shift stack left (to an empty stack)

And another one that's a mirror image around a central point.

# Ly, 21 bytes

<<'<::+/'upu'\+::>'>>

Try it online!

# QBasic (QB64)

X = Y = Z
PRINT ATN(X) / ATN(X / Y)

All variables in QBasic are initialized to 0. The first line is X = (Y = Z), where the first = is assignment but the second = is comparison. Truthy is -1 in QBasic, so now X is -1. QB64 allows division by 0, returning floating point infinity (or in this case, negative infinity); $$\\arctan(-1) = -\frac \pi 4\$$, and $$\\arctan(-\infty) = -\frac \pi 2\$$.

# Desmos, 23 bytes

\frac{\{\}}{\{\}+\{\}}

(newline is required)

Looks crazy, but it really isn't once you figure out that \{\} is just 1.

The actual crazy part is that it doesn't render properly on Desmos, though it still outputs 0.5.

Try It On Desmos!

• Using forward slash: ¶\{\}/(\{\}+\{\}) ( is newline) – fireflame241 Jun 21 at 6:30
• @fireflame241 Yes, I know that works, but I wanted to have more brackets in the code to make it look more crazy :P. – Aiden Chow Jun 21 at 6:46
• Oh it's a pop-con. Forgot to read the question, oh well. – fireflame241 Jun 21 at 6:47

# Factor + math.unicode

½ .

Try it online!

Or, slightly more interesting: since Factor has a ton of constants and helper words named a, b, c, etc. in private vocabularies, I thought it would be fun to see how far down the alphabet I had to go before arriving at a solution. Turns out not very far. I struck gold with the word a from the math.finance.private vocabulary which is defined as : a ( n -- a ) 1 + 2 swap / ; inline Or, in math terms: $$\a(n)=\frac{2}{n+1}\$$. Then, I just had to find a value of $$\3\$$ which turns out to be defined in checksums.md5.private as CONSTANT: d 3 inline. So:

d a .

Try it online!