<commit_before>var puzzle;
var rowClues;
var colClues;

function createPixel (state, id) {
  return {
    chosen: state == 1,
    flagged: state == 2,
    id: id
  };
}

function createRow (rawRow, rowIndex) {
  return {
    pixels: rawRow.map(function (state, colIndex) {
      return createPixel(state, rowIndex + colIndex);
    })
  };
}

function sameRow (row1, row2) {
  var arr1 = row1.pixels;
  var arr2 = row2.pixels;
  if (row1.length != row2.length) return false;
  for (var i = 0; i < row1.length; i++) {
    if (arr1[i].chosen != arr2[i].chosen) return false;
  }
  return true;
}

function createClue (num) {
  return {
    completed: false,
    num: num
  };
}

function clues (series) {
  var clueArr = [];
  var current = 0;
  for (var i = 0; i < series.length; i++) {
    if (series[i].chosen) {
      current++;
    } else if (current) {
      clueArr.push( createClue(current) );
      current = 0;
    }
  }
  if (current > 0 || clueArr.length === 0) {
    clueArr.push( createClue(current) );
  }
  return clueArr;
}

function createPuzzle (rawPuzzle) {
  return {
    rows: rawPuzzle.map(function (rawRow, rowIndex) {
      return createRow(rawRow, String.fromCharCode(65 + rowIndex));
    }),
    size: rawPuzzle.length
  };
}

function samePuzzle (puzzle1, puzzle2) {
  var arr1 = this.rows;
  var arr2 = puzzle.rows;
  if (puzzle1.size != puzzle2.size) return false;
  for (var i = 0; i < puzzle1.size; i++) {
    if (!sameRow(arr1[i], arr2[i])) return false;
  }
  return true;
}

function rotate (puzzle) {
  var rot = [];

  for (var i = 0; i < puzzle.size; i++) {
    var col = [];
    for (var j = 0; j < puzzle.size; j++) {
      var state = (puzzle.rows[j].pixels[i].chosen) ? 1 : 0;
      col.unshift(state);
    }
    rot.push(col);
  }
  return createPuzzle(rot);
}

function updateClueStatus (puzzle) {
  function clearRow (row) {
    row.forEach(function (clue) {
      clue.completed = false;
    });
  }
  // Rows
  puzzle.rows.forEach(function (row, index) {
    var guess = clues(row.pixels);
    clearRow(rowClues[index]);
    var size = guess.length < rowClues[index].length ? guess.length : rowClues[index].length;
    for (var j = 0; j < size; j++) {
      var clue = rowClues[index][j];
      clue.completed = clue.num == guess[j].num;
    }
  });
  // Columns
  rotate(puzzle).rows.forEach(function (row, index) {
    var guess = clues(row.pixels);
    var size = guess.length < colClues[index].length ? guess.length : colClues[index].length;
    clearRow(colClues[index]);
    for (var j = 0; j < size; j++) {
      var clue = colClues[index][j];
      clue.completed = clue.num == guess[j].num;
    }
  });
}

function puzzleDone () {
  var done = true;
  [rowClues, colClues].forEach(function (rows) {
    rows.forEach(function (row) {
      row.forEach(function (clue) {
        done = done && clue.completed;
      });
    });
  });
  return done;
}

angular.module("gitcross", [])
.controller("PuzzleCtrl", function ($scope, $http, goinstant) {
  function newGame (difficulty) {
    $http.get("/puzzles/?size=" + difficulty).then(function (res) {
      $scope.done = false;<commit_msg>Reverse the testing of column clues<commit_after>var puzzle;
var rowClues;
var colClues;

function createPixel (state, id) {
  return {
    chosen: state == 1,
    flagged: state == 2,
    id: id
  };
}

function createRow (rawRow, rowIndex) {
  return {
    pixels: rawRow.map(function (state, colIndex) {
      return createPixel(state, rowIndex + colIndex);
    })
  };
}

function sameRow (row1, row2) {
  var arr1 = row1.pixels;
  var arr2 = row2.pixels;
  if (row1.length != row2.length) return false;
  for (var i = 0; i < row1.length; i++) {
    if (arr1[i].chosen != arr2[i].chosen) return false;
  }
  return true;
}

function createClue (num) {
  return {
    completed: false,
    num: num
  };
}

function clues (series) {
  var clueArr = [];
  var current = 0;
  for (var i = 0; i < series.length; i++) {
    if (series[i].chosen) {
      current++;
    } else if (current) {
      clueArr.push( createClue(current) );
      current = 0;
    }
  }
  if (current > 0 || clueArr.length === 0) {
    clueArr.push( createClue(current) );
  }
  return clueArr;
}

function createPuzzle (rawPuzzle) {
  return {
    rows: rawPuzzle.map(function (rawRow, rowIndex) {
      return createRow(rawRow, String.fromCharCode(65 + rowIndex));
    }),
    size: rawPuzzle.length
  };
}

function samePuzzle (puzzle1, puzzle2) {
  var arr1 = this.rows;
  var arr2 = puzzle.rows;
  if (puzzle1.size != puzzle2.size) return false;
  for (var i = 0; i < puzzle1.size; i++) {
    if (!sameRow(arr1[i], arr2[i])) return false;
  }
  return true;
}

function rotate (puzzle) {
  var rot = [];

  for (var i = 0; i < puzzle.size; i++) {
    var col = [];
    for (var j = 0; j < puzzle.size; j++) {
      var state = (puzzle.rows[j].pixels[i].chosen) ? 1 : 0;
      col.unshift(state);
    }
    rot.push(col);
  }
  return createPuzzle(rot);
}

function updateClueStatus (puzzle) {
  function clearRow (row) {
    row.forEach(function (clue) {
      clue.completed = false;
    });
  }
  // Rows
  puzzle.rows.forEach(function (row, index) {
    var guess = clues(row.pixels);
    clearRow(rowClues[index]);
    var size = guess.length < rowClues[index].length ? guess.length : rowClues[index].length;
    for (var j = 0; j < size; j++) {
      var clue = rowClues[index][j];
      clue.completed = clue.num == guess[j].num;
    }
  });
  // Columns
  rotate(puzzle).rows.forEach(function (row, index) {
    var guess = clues(row.pixels).reverse();
    var size = guess.length < colClues[index].length ? guess.length : colClues[index].length;
    clearRow(colClues[index]);
    var col = _(colClues[index]).clone().reverse();
    for (var j = 0; j < size; j++) {
      var clue = col[j];
      clue.completed = clue.num == guess[j].num;
    }
  });
}

function puzzleDone () {
  var done = true;
  [rowClues, colClues].forEach(function (rows) {
    rows.forEach(function (row) {
      row.forEach(function (clue) {
        done = done && clue.completed;
      });
    });
  });
  return done;
}

angular.module("gitcross", [])
.controller("PuzzleCtrl", function ($scope, $http, goinstant) {
  function newGame (difficulty) {
    $http.get("/puzzles/?size=" + difficulty).then(function (res) {
      $scope.done = false;
{'fraction_non_alphanumeric': 0.16146817895400126, 'fraction_numerical': 0.011657214870825458, 'mean_word_length': 2.8831804281345565, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3703663', 'n_tokens_mistral': 2369, 'n_tokens_neox': 2295, 'n_words': 549}