Cursed Javascript Code That Obfuscates the Number One
Description
A screenshot of a Javascript code snippet consisting of 20 lines in a dark-themed editor. The code defines 17 constant variables, from 'a' to 'z', each assigned the result of a fractional division. The main logic is a single `console.log` statement which calculates `(n*e*g*a*t*i*v*e * e*i*g*h*t + e*l*e*v*e*n) / 3`. The variable names are intentionally chosen so that their multiplication spells out the words "negative", "eight", and "eleven", which evaluate to -1, 8, and 11 respectively. The result of this entire convoluted expression is simply the number 1. The humor lies in the extreme obfuscation and deliberate violation of clean code principles to create a "cursed" piece of code that is both clever and completely unreadable, a common trope in developer humor. The comment `//works for -11 to 11` appears to be a red herring or part of the joke, as the calculation is deterministic
Comments
40Comment deleted
This isn't just tech debt, this is a tech federal default. You don't refactor this, you declare bankruptcy on the entire repo
Some engineers optimize for O(1); this one optimizes for OMG(why) - review approved only if the next commit replaces the build script with a haiku
This is what happens when you ask a mathematician to implement i18n - they'll prove it works for all integers from -11 to 11, but good luck explaining it to the junior who inherits this codebase after your 'clever' solution ships to production
When your code review reveals that someone spent an hour crafting integer divisions to spell 'negative eight eleven' through variable arithmetic instead of just using a string literal, you know they've achieved that perfect balance between 'technically correct' and 'why though?' that defines senior engineering. It's the programming equivalent of using a Rube Goldberg machine to flip a light switch - impressively unnecessary, yet somehow respectable
Comprehensive test coverage: validates flawlessly from -11 to 11. Prod-ready!
JavaScript lets you cancel letters like fractions; your code reviewer will cancel the PR even faster
At last, a way to satisfy “no magic numbers” and “descriptive names” simultaneously - the VM constant‑folds it to 3 while the reviewer solves an English word sudoku
Still more legible than APL one-liner. Comment deleted
I'm afraid to type this in my repl... Comment deleted
Wtf Comment deleted
For anyone who wants to test const a = -3 / 80; const e = 1; const f = 5; const g = 8 / 3; const h = 9 / 10; const i = 1; const l = 11 / 3; const n = 3; const o = 1 / 3; const r = 1; const s = 7 / 3; const t = 10 / 3; const u = 12 / 5; const v = 1; const w = 9 / 5; const x = 18 / 7; const z = 0; Comment deleted
what's 9 + 10 Comment deleted
tweny wan Comment deleted
21 Comment deleted
"Linus Torvalds, I think we need to kill this guy" "Damn" Comment deleted
Well, technically this is 18 lines of code☝️🤓 Comment deleted
console.log(n*e*g*a*t*i*v*e); console.log(o*n*e); console.log(t*w*o); console.log(t*h*r*e*e); console.log(f*o*u*r); console.log(f*i*v*e); console.log(s*i*x); console.log(s*e*v*e*n); console.log(e*i*g*h*t); console.log(n*i*n*e); console.log(t*e*n); console.log(e*l*e*v*e*n); Comment deleted
You solve set of this equations I guess Comment deleted
you forgor zero Comment deleted
You are right, though it is trivial. "z=0" means any "e","r","o" will work Comment deleted
Lol Comment deleted
how do you even come up with this? is there a formula, or just suicidal bruteforce? Comment deleted
matrix solver Comment deleted
honestly i'm surprised this is even solvable Comment deleted
actually no, I'm wrong. this isn't where matrices work. also there are way more variables than equations, and that means it's easier it basically solves like sudoku for instance only one of variables can be 0, and only the one that is only present in the word "zero" - so it's "z" Comment deleted
oh nice, that makes sense, like sudoku backtracking. a bit of math and a bit of bruteforce solves so much lol Comment deleted
it works just fine if you take logarithm of each value Comment deleted
i very much doubt the sudoku-style approach actually works here Comment deleted
It does but can't solve it by itself Comment deleted
I would need an initial guess. By gut you can tell "e" has to be 1. The rest must be solvable step by step Comment deleted
it is indeed sudoku Comment deleted
It was written inside the ancient pyramids Comment deleted
As to me, pure 754 number "4" 🧐 Comment deleted
If OP imported an arbitrary-precision math lib, this wouldn't happen Comment deleted
still less cool than that one legendary regexp that looks like gibberish but eventually, after many rounds of grouping and capturing on itself resolves to rm -rf / or smth like that 😇 Comment deleted
Gimme his drug dealer phone number 🥴 Comment deleted
what the fuck am i looking at Comment deleted
What? Comment deleted
What the fuck Comment deleted
This shit is still amazing to me In case if you want to share it with someone: const a = -3 / 80; const e = 1; const f = 5; const g = 8 / 3; const h = 9 / 10; const i = 1; const l = 11 / 3; const n = 3; const o = 1 / 3; const r = 1; const s = 7 / 3; const t = 10 / 3; const u = 12 / 5; // Note: 'u' is needed for 'four' const v = 1; const w = 9 / 5; const x = 18 / 7; const z = 0; // These 'words' evaluate correctly using the constants above const zero = z*e*r*o; // = 0 const one = o*n*e; // = 1 const two = t*w*o; // = 2 const three = t*h*r*e*e; // = 3 const four = f*o*u*r; // = 4 const five = f*i*v*e; // = 5 const six = s*i*x; // = 6 const seven = s*e*v*e*n; // = 7 const eight = e*i*g*h*t; // = 8 const nine = n*i*n*e; // = 9 const ten = t*e*n; // = 10 const eleven = e*l*e*v*e*n; // = 11 const negative= n*e*g*a*t*i*v*e; // = -1 // --- Examples of Arithmetic within the -100 to +100 range --- // Original example: console.log(negative * eight + eleven); // -1 * 8 + 11 = 3 // Examples producing results between -100 and 100: console.log(ten * nine); // 10 * 9 = 90 console.log(negative * ten * nine); // -1 * 10 * 9 = -90 console.log(eleven * nine); // 11 * 9 = 99 console.log(negative * eleven * nine); // -1 * 11 * 9 = -99 console.log(ten * ten); // 10 * 10 = 100 console.log(negative * ten * ten); // -1 * 10 * 10 = -100 console.log(eight * seven + five); // 8 * 7 + 5 = 56 + 5 = 61 console.log(six * nine - four); // 6 * 9 - 4 = 54 - 4 = 50 console.log(three + five * ten); // 3 + 5 * 10 = 3 + 50 = 53 console.log(negative * (six * seven)); // -1 * (6 * 7) = -42 console.log(zero); // 0 console.log(ten + one); // 10 + 1 = 11 console.log(negative * five); // -1 * 5 = -5 Comment deleted