Skip to content

Instantly share code, notes, and snippets.

function numberOfAnagrams(S) {

  // S.length!/repeat!
  
  var total = factorial(S.length),
	repeat = 1,
      array = S.split('').sort();
  
  for (var i=1;i<array.length;i++) {
function blackOrWhite(s) { // true: black, false: white
  var vertical = s[0].charCodeAt(0) - 'a'.charCodeAt(0) + 1;
  var horizon = s[1];
  if (vertical % 2 == 1) { // vertical odd
    if (horizon % 2 == 0) { // horizon even
      return false;
    }
    return true;
  } else { // vertical even