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.
std::vector<std::string>bomberMan(intn,std::vector<std::string>grid){autoblowTargets=[](std::vector<std::string>const&targets){autorows=targets.size();autocolumns=targets.front().size();// This mixes the step where we plant bombs in the whole grid // and then we blow up the previous bombs...std::vector<std::string>ret(targets.size(),std::string(columns,'O'));for(intr=0;r<rows;++r){for(intj=0;j<columns;++j){if(targets[r][j]!='O')continue;ret[r][j]='.';if(j>0)ret[r][j-1]='.';// LEFTif(j+1<columns)ret[r][j+1]='.';// RIGHTif(r>0)ret[r-1][j]='.';// UPif(r+1<rows)ret[r+1][j]='.';// DOWN}}returnret;};if(n<3)returngrid;if(n%2==0)// On even seconds, the entire grid is filled with bombs.{returnstd::vector<std::string>(grid.size(),std::string(grid.front().size(),'O'));}if(n%4==3)returnblowTargets(grid);returnblowTargets(blowTargets(grid));}
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 →