The Bomberman Game

Sort by

recency

|

13 Discussions

|

  • + 0 comments

    Finding out about the effect of AI and IoT on organizations is significant on the off chance that you need to prevail in the innovation business. The teqatlas.com site has some profitable research which will be useful for you. There's no price for this research.

  • + 0 comments

    I love playing the Bomberman game so much! It's one of the best games that's ever been created. Some of the custom essay writing service reviews people that I work with say the same thing. Now, I know why so many people are fond of this game.

  • + 0 comments

    I have coded the problem with O(n^3) but it is getting timed out for latter cases. can it be transformable to O(n^2) anyhow ?

  • [deleted]
    + 1 comment

    Here's my sol


    public class Solution {

    static void blast(char[][] grid,int i,int j,int[][] secPlanted){
        grid[i][j]='.';
        try{
            if(grid[i][j+1]=='O'&&secPlanted[i][j+1]==3){
                blast(grid,i,j+1,secPlanted);
            }
            grid[i][j+1]='.';
            secPlanted[i][j+1]=0;
        }catch(ArrayIndexOutOfBoundsException e){}
        try{
            if(grid[i][j-1]=='O'&&secPlanted[i][j-1]==3){
                blast(grid,i,j-1,secPlanted);
            }
            grid[i][j-1]='.';
            secPlanted[i][j-1]=0;
        }catch(ArrayIndexOutOfBoundsException e){}
        try{
            if(grid[i-1][j]=='O'&&secPlanted[i-1][j]==3){
                blast(grid,i-1,j,secPlanted);
            }
            grid[i-1][j]='.';
            secPlanted[i-1][j]=0;
        }catch(ArrayIndexOutOfBoundsException e){}
        try{
            if(grid[i+1][j]=='O'&&secPlanted[i+1][j]==3){
                blast(grid,i+1,j,secPlanted);
            }
            grid[i+1][j]='.';
            secPlanted[i+1][j]=0;
        }catch(ArrayIndexOutOfBoundsException e){}
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r=sc.nextInt(),c=sc.nextInt(),n=sc.nextInt();
        String[] gridString = new String[r];
        int sec=0;
        char[][] grid = new char[r][c];
        for(int i=0;i<r;i++){
            gridString[i]=sc.next();
            grid[i]=gridString[i].toCharArray();
        }
        sec++;//1 sec
        sec++;//2 secs
        int[][] secPlanted = new int[r][c];
        for(int i=0;i<r;i++){
            for(int j=0;j<c;j++){
                secPlanted[i][j] = grid[i][j]=='O'?2:0; 
            }
        }
        while(sec<=n){
            while(n-sec>4)
                sec+=4;
            //fill empty places
            if(sec%2==0){
                for(int i=0;i<r;i++)
                    for(int j=0;j<c;j++)
                        if(grid[i][j]=='.')
                            grid[i][j]='O';
            }
    
            //bomb blast
            if(sec%2==1){
                for(int i=0;i<r;i++){
                    for(int j=0;j<c;j++){
                        if(secPlanted[i][j]==3){
                            secPlanted[i][j]=0;
                            blast(grid,i,j,secPlanted);
                        }
                    }
                }
            }
            for(int i=0;i<r;i++)
                for(int j=0;j<c;j++)
                    secPlanted[i][j] = grid[i][j]=='O' ? secPlanted[i][j]+1 : 0;
            sec++;
    
        }
    
        //final grid
        for(int i=0;i<r;i++){
            for(int j=0;j<c;j++)
                System.out.print(grid[i][j]);
            System.out.println();
        }
    }
    

    }

  • + 0 comments

    code is terminating due to timeout for large n. Obviously,array will take time to orient itself. How to optimise it?

    /