Simple and easy algorithms to impress your boss Elon Musk

Chris Engelsma
2 min readNov 25, 2022
Photo by Joan Gamell on Unsplash

We all know that the only true marker of a developer’s success is through lines of code written.

Don’t believe me? Take it from apartheid emerald mine heir and famous fail-forward billionaire Elon Musk, who used this very metric to determine which employees stay and which ones go. Never mind if you’re a system architect, devops, technical ops, database admin, system security admin, etc.

Nope, lines of code, baby.

So since verbosity is now apparently how we measure engineer productivity, here are some algorithms you can use to boost your LOC number.

1. Finding an odd number

Old way:

function isOdd(value) {
return (value % 2) > 0;
}

Yuck. Short, concise, this is how the middle class codes.

Better, billionaire-genius way:

function isOdd(value) {
const strVal = value.toString();
for (let i = 0; i < strVal.length; ++i) {
if (i === strVal.length - 1) {
continue;
} else {
switch (strVal[i]) {
case ‘0’:
return true;
break;
case ‘1’:
return false;
break;
case ‘2’…

--

--

Chris Engelsma
Chris Engelsma

Written by Chris Engelsma

Geophysicist, software engineer, and web developer. Hopefully if I throw enough spaghetti at the wall something sticks.