You are viewing a single comment's thread. Return to all comments →
this is my solution but i'm not still solved the time limit exceeded
fun bomberMan(n: Int, grid: Array<String>): Array<String> { if (n <=1) { return grid } if (n%2 == 0) { return Array(grid.size){ "O".repeat(grid.get(0).length) } } var times = (n-3)/2 + 1 var response = grid do { response = response.mapIndexed { yindex, row -> val columns = row.toCharArray() columns.mapIndexed {xindex, column -> when { xindex>0 && columns[xindex -1] == 'O' || xindex+1 < columns.size && columns[xindex+1] == 'O' || yindex>0 && response[yindex -1].get(xindex) == 'O' || yindex+1 < response.size && response[yindex +1].get(xindex) == 'O' || column == 'O' -> "." else -> "O" } }.joinToString("") }.toTypedArray() times-- } while(times > 0) return response }
Seems like cookies are disabled on this browser, please enable them to open this website
The Bomberman Game
You are viewing a single comment's thread. Return to all comments →
this is my solution but i'm not still solved the time limit exceeded