Skip to main content
deleted 2 characters in body; edited tags
Source Link
Riker
  • 7.9k
  • 4
  • 39
  • 73

I'm new to ES6 and code-golfing. Here's the original function(){}:

function puzzle(n, x) {
  return n * Math.pow(2, x);
}

And here's what I have so far =>:

let puzzle=(n,x)=>n*2<<(x-1)

But the solution requires lesser characters. I went through the 'Code Golfing with ES6' thread,but but couldn't find a better way. Any help/links would be appreciated.

I'm new to ES6 and code-golfing. Here's the original function(){}

function puzzle(n, x) {
  return n * Math.pow(2, x);
}

And here's what I have so far =>

let puzzle=(n,x)=>n*2<<(x-1)

But the solution requires lesser characters. I went through the 'Code Golfing with ES6' thread,but couldn't find a better way. Any help/links would be appreciated.

I'm new to ES6 and code-golfing. Here's the original function:

function puzzle(n, x) {
  return n * Math.pow(2, x);
}

And here's what I have so far:

let puzzle=(n,x)=>n*2<<(x-1)

But the solution requires lesser characters. I went through the 'Code Golfing with ES6' thread, but couldn't find a better way. Any help/links would be appreciated.

edited tags
Link
Leaky Nun
  • 50.1k
  • 6
  • 110
  • 284

Code Golf Javascript tips: 2 to the power of x multiplied by n

Source Link

Code Golf: 2 to the power of x multiplied by n

I'm new to ES6 and code-golfing. Here's the original function(){}

function puzzle(n, x) {
  return n * Math.pow(2, x);
}

And here's what I have so far =>

let puzzle=(n,x)=>n*2<<(x-1)

But the solution requires lesser characters. I went through the 'Code Golfing with ES6' thread,but couldn't find a better way. Any help/links would be appreciated.