Skip to content

Instantly share code, notes, and snippets.

@thrashr888
Created July 19, 2012 15:49
Show Gist options
  • Select an option

  • Save thrashr888/3144853 to your computer and use it in GitHub Desktop.

Select an option

Save thrashr888/3144853 to your computer and use it in GitHub Desktop.
// codetest.js
// Given initial state of a minesweeper board
var COLS = 8;
var ROWS = 8;
var DIFFICULTY = 0.2;
var mines = [];
for (var i = 0 ; i < COLS ; ++i){
mines[i] = [];
for(var j = 0 ; j < ROWS ; ++j){
mines[i][j] = Math.random() > DIFFICULTY;
}
}
console.log(mines.join('<p>'));
// write a function that takes a row and column as parameters and returns the number of adjacent mines. How the value of "the input location is a mine" is handled is left as an exercise to the reader.
// you have 40 minutes to complete the test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment