We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
If N = 1, then we just print the initial board, as Bomberman hasn't put any new bombs on it;
If we look at the board starting from second N = 2, we'll see a pattern. On every even time N, Bomberman will fill the empty spaces with bombs and, on every odd time N, he will observe some of them exploding. Then, without doing any unnecessary computation, we can say for sure that, if N is even, then the board will be full of bombs;
If you look at the remaining possible values of N (N >= 3 and N is odd), you'll see that there's a very clear pattern. Thanks to it, you can assure that there are only two possibilities of board configurations for those values and deciding between them is as easy as applying a simple math operator to N;
Using these previous 3 tips, you can simplify your problem. Instead of keeping track of the number of seconds remaining for a bomb to detonate, you can just keep an eye on those that will explode next.
Cookie support is required to access HackerRank
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 →
A few useful tricks for this problem:
If N = 1, then we just print the initial board, as Bomberman hasn't put any new bombs on it;
If we look at the board starting from second N = 2, we'll see a pattern. On every even time N, Bomberman will fill the empty spaces with bombs and, on every odd time N, he will observe some of them exploding. Then, without doing any unnecessary computation, we can say for sure that, if N is even, then the board will be full of bombs;
If you look at the remaining possible values of N (N >= 3 and N is odd), you'll see that there's a very clear pattern. Thanks to it, you can assure that there are only two possibilities of board configurations for those values and deciding between them is as easy as applying a simple math operator to N;
Using these previous 3 tips, you can simplify your problem. Instead of keeping track of the number of seconds remaining for a bomb to detonate, you can just keep an eye on those that will explode next.