Created
February 19, 2016 18:52
-
-
Save aziflaj/7dec24bf151d34f2fe6c to your computer and use it in GitHub Desktop.
AI Playground http://aichallenges.appspot.com/mainpage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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