Skip to content

Instantly share code, notes, and snippets.

@aziflaj
Created February 19, 2016 18:52
Show Gist options
  • Save aziflaj/7dec24bf151d34f2fe6c to your computer and use it in GitHub Desktop.
Save aziflaj/7dec24bf151d34f2fe6c to your computer and use it in GitHub Desktop.
// http://aichallenges.appspot.com/intro
function rotateRow(row) {
var len = row.length;
for (var i = 0; i < len/2; i++) {
var tmp = row[i];
row[i] = row[len - 1 - i];
row[len - 1 - i] = tmp;
}
return row;
}
this.run = function(map) {
var tempMap = map;
var rows = tempMap.length;
for (var i = 0; i < rows / 2; i++) {
var tmp = tempMap[i];
tempMap[i] = tempMap[rows - 1 - i];
tempMap[rows - 1 - i] = tmp;
tempMap[i] = rotateRow(tempMap[i]);
tempMap[rows - 1 - i] = rotateRow(tempMap[rows - 1 - i]);
}
return tempMap;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment