Ad
Refactoring
Mathematics

I've been recently dealing with the problem of integers literals being too readable and efficient and I mean look at this literal: 6, it's too simple!

For this task we'll unoptimize a function called itoi wich stands for "integer to integer", it'l take as input an integer and will output the same value in strage and bizarre ways in order to largely decrease efficiency, one liners are encouraged.

In code's playful realm, we weave a disguise,
With cryptic constructs that confound the wise.
Ternaries and tricks, a maze to explore,
A challenge to fathom, and then some more.

JavaScript joins, a quirky domain,
Its strengths and its quirks, a unique refrain.
Yet coding's the art where all minds unite,
In clever endeavors, we find our delight.

WARNING!
test cases will be small to allow for far worse efficiency!

const integer_dark_magic = (integer, index) => !(index == false)? integer_dark_magic(integer + (((index > 0)? 1 : 0)* 2 - 1), index - (((index > 0)? 1 : 0)* 2 - 1) * (false ? [].length : integer_dark_magic(1, false))) : integer;
                                         //termination condition              chose wether subtract or increment the integer, the opposite of that but with the index
const itoi = (integer) => integer_dark_magic(0, integer);
Code
Diff
  • const reverseGear=w=>[...w].reverse().join('')
    • const reverseGear=(word)=>[...word].reduce((a,b)=>b+a,'')
    • const reverseGear=w=>[...w].reverse().join('')