Quotes help make search much faster. Example: "Practice Makes Perfect"

Saturday, December 10, 2016

Codefights swapAdjacentBits


//sample solution
//2863311530 is the decimal equivalent of 10101010101010101010101010101010
//1431655765 is the decimal equivalent of 01010101010101010101010101010101

function swapAdjacentBits(n) {
  return ((n & 2863311530) >> 1) | ((n & 1431655765) << 1);
}

No comments:

Post a Comment


This is an example of scrolling text using Javascript.

Popular Posts