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.
defbomberMan(n,grid):# Write your code heredefexplode(gr):bombs=[(i,j)fori,lineinenumerate(gr)forjinrange(len(line))ifgr[i][j]=='O']deton=[(i+1,j)fori,jinbombsifi+1<len(gr)]deton=deton+[(i,j+1)fori,jinbombsifj+1<len(gr[0])]deton=deton+[(i-1,j)fori,jinbombsifi-1>=0]deton=deton+[(i,j-1)fori,jinbombsifj-1>=0]gri=['O'*len(grid[0])]*len(grid)fori,jinbombs+deton:gri[i]=gri[i][0:j]+'.'+gri[i][j+1:len(gri[i])]returngriif0<=n<=1:returngridifn%2<=0:return['O'*len(grid[0])]*len(grid)ifn%4==1:returnexplode(explode(grid))ifn%4==3:returnexplode(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 →