<commit_before>var Grid = function(width, height) {
  var dataSource = [];
  var nextDataSource = [];

  function createDataSource() {
      var data = [];
      
      //create rows 
      for (var i=0; i < height; i+=1) {    
        data[i] = [];
        
        for (var j=0; j < width; j+=1) {
          data[i][j] = false;          
        }      
      }
      
      return data;
  }
  
  function calculate() {
    nextDataSource = [];
    
    for (var i=0; i < height; i+=1) {    
      nextDataSource[i] = [];
      
      for (var j=0; j < width; j+=1) {
        count = countAround(i,j);
        
        // do some logic on the count and set the data
        if (count == 3) {
          nextDataSource[i][j] = true;
        }
        
        if (count == 2) {
          nextDataSource[i][j] = dataSource[i][j];
        }
      }      
    }  
  }
  
  // show the number of active items surrounding the row and column
  function countAround(row, column) {
    function up() { row -= 1 }
    
    function right() { column += 1 }
    
    function down() { row += 1 }
    
    function left() { column -= 1 }
        
    var count = 0;

    up();
    
    count += public.getCell(row, column);

    right();
    
    count += public.getCell(row, column);
    
    down();
    
    count += public.getCell(row, column);
    
    down();
    
    count += public.getCell(row, column);
    
    left();
    
    count += public.getCell(row, column);
        
    left();
    
    count += public.getCell(row, column);
    
    up();

    count += public.getCell(row, column);    
    
    up();
    
    count += public.getCell(row, column);
    
    return count;
  }
  
  function activate() {
    dataSource = nextDataSource;
  }
  
  dataSource = createDataSource();
  
  var public = {
    data: function(){
      return dataSource;
    },
    
    columns: function() {
      return {<commit_msg>Simplified the countAround function<commit_after>var Grid = function(width, height) {
  var dataSource = [];
  var nextDataSource = [];

  function createDataSource() {
      var data = [];
      
      //create rows 
      for (var i=0; i < height; i+=1) {    
        data[i] = [];
        
        for (var j=0; j < width; j+=1) {
          data[i][j] = false;          
        }      
      }
      
      return data;
  }
  
  function calculate() {
    nextDataSource = [];
    
    for (var i=0; i < height; i+=1) {    
      nextDataSource[i] = [];
      
      for (var j=0; j < width; j+=1) {
        count = countAround(i,j);
        
        // do some logic on the count and set the data
        if (count == 3) {
          nextDataSource[i][j] = true;
        }
        
        if (count == 2) {
          nextDataSource[i][j] = dataSource[i][j];
        }
      }      
    }  
  }
  
  // show the number of active items surrounding the row and column
  function countAround(row, column) {
    var directions = {
      up:     function() { row    -= 1 },
      right:  function() { column += 1 },
      down:   function() { row    += 1 },
      left:   function() { column -= 1 }
    }
    
    var count = 0;
    var actions = ["up", "right", "down", "down", "left", "left", "up", "up"];
    
    for (var i = 0; i < actions.length; i+=1) {
      directions[actions[i]]();
      count += public.getCell(row, column);
    }
    
    return count;
  }
  
  function activate() {
    dataSource = nextDataSource;
  }
  
  dataSource = createDataSource();
  
  var public = {
    data: function(){
      return dataSource;
    },
    
    columns: function() {
      return {
{'fraction_non_alphanumeric': 0.1425006930967563, 'fraction_numerical': 0.00887163848073191, 'mean_word_length': 1.571632216678546, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 3, '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': '7537115', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1143, 'n_words': 296}