Skip to main content
added 28 characters in body
Source Link
_ =>                                     // input i.e : the original array
    _.map(                               // map over all elements of the array
        eval('                           // eval a string
            for(v=_/(d=~~(_*.5d=_>>1);            // set v = _ / floor(_ *>> 0.5)1 and set that to d
                v!=~~v;)                  // and keep going until v !== floor(v)
                        v=_/d--);             // subtract from d
                        v = _/d;         // set v to _ / d again (d was changed)
                    d'                   // return d
            ))                           // end eval and map and function

This is still for old code haven't updated this.

_ =>                                     // input i.e : the original array
    _.map(                               // map over all elements of the array
        eval('                           // eval a string
            for(v=_/(d=~~(_*.5);         // set v = _ / floor(_ * 0.5) and set that to d
                v!=~~v;)                 // and keep going until v !== floor(v)
                        d--;             // subtract from d
                        v = _/d;         // set v to _ / d again (d was changed)
                    d'                   // return d
            ))                           // end eval and map and function
_ =>                                     // input i.e : the original array
    _.map(                               // map over all elements of the array
        eval('                           // eval a string
            for(v=_/(d=_>>1);            // set v = _ / _ >> 1 and set that to d
                v!=~~v;                  // and keep going until v !== floor(v)
                        v=_/d--);        // to _ / d again (d was changed)
                    d'                   // return d
            ))                           // end eval and map and function

This is still for old code haven't updated this.

added 28 characters in body
Source Link

JavaScript (Node.js), 616155 bytes

-6 bytes thanks to @shaggy

_=>_.map(_=>eval('for(v=_/(d=~~(_*.5)d=_>>1);v!=~~v;)d=~~v;v=_/--,v=_/d;d'd);d'))

Try it online!Try it online!

JavaScript (Node.js), 61 bytes

_=>_.map(_=>eval('for(v=_/(d=~~(_*.5));v!=~~v;)d--,v=_/d;d'))

Try it online!

JavaScript (Node.js), 6155 bytes

-6 bytes thanks to @shaggy

_=>_.map(_=>eval('for(v=_/(d=_>>1);v!=~~v;v=_/--d);d'))

Try it online!

added 6 characters in body
Source Link

A lot more un-golfed ES5 friendly as well:

 const fprimeOrNot = function(input) { // the function f with argument input
      return input.map(function(value) { // returns the array after mapping over them
           d = Math.floor(value * 0.5); // multiply each element by 0.5 and floor it 
           for(let v = value / d; v != Math.floor(v);) { // for loop goes until v!=~~v
                d --; // subtract one from d
                v = value / d; // set v again to value / d
           }
           return d; // return d
      })
 };

A lot more un-golfed :

 const f = function(input) { // the function f with argument input
      return input.map(function(value) { // returns the array after mapping over them
           d = Math.floor(value * 0.5); // multiply each element by 0.5 and floor it 
           for(let v = value / d; v != Math.floor(v);) { // for loop goes until v!=~~v
                d --; // subtract one from d
                v = value / d; // set v again to value / d
           }
           return d; // return d
      })
 };

ES5 friendly as well:

 const primeOrNot = function(input) { // the function with argument input
      return input.map(function(value) { // returns the array after mapping over them
           d = Math.floor(value * 0.5); // multiply each element by 0.5 and floor it 
           for(let v = value / d; v != Math.floor(v);) { // for loop goes until v!=~~v
                d --; // subtract one from d
                v = value / d; // set v again to value / d
           }
           return d; // return d
      })
 };
added 697 characters in body
Source Link
Loading
added 697 characters in body
Source Link
Loading
added 697 characters in body
Source Link
Loading
Source Link
Loading