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.
The idea to grasp is that after the first time instant (n=1), the grid keeps toggling between 3 possible configurations.
So after generating the 3 patterns, we need to notice that the patterns keep repeating in the order(set no.) :
. . . . . . . . 3 1 2 1 3 1 2 1 3 1 2 1 . . . . . . . . with a net frequency of 4
So if n is even, print set 1.
If n is odd and n%4 is 1, print set 3.
If n is odd and n%4 is 3, print set 2.
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 →
The idea to grasp is that after the first time instant (n=1), the grid keeps toggling between 3 possible configurations.
So after generating the 3 patterns, we need to notice that the patterns keep repeating in the order(set no.) : . . . . . . . . 3 1 2 1 3 1 2 1 3 1 2 1 . . . . . . . . with a net frequency of 4
So if n is even, print set 1.
If n is odd and n%4 is 1, print set 3.
If n is odd and n%4 is 3, print set 2.