Thread: Grid of mines?

  1. #1
    Registered User
    Join Date
    Aug 2014
    Posts
    2

    Grid of mines?

    Code:
    There is a rectangular grid of numbers. The grid has m rows and n columns. So it has m*n cells in total.The rows are numbered from 1 to m and the columns are numbered from 1 to n. The top most row has number 1, the row next to it has number 2 and so on. Similarly, the left most column has number 1, the column next to it has number 2 and so on. Each cell in the grid has a unique coordinate which is (x, y) where x is the row number and y is the column number of that particular cell.
    
    
    Each cell in the grid has an integer in {0, 1, 2, 3, 4, 5, 6 ,7 ,8}. Number in cell (x,y) is number of mines in neighboring cells (cells have at least 1 common vertex with cell (x,y))
    Your task is to find grid of mines, i.e display an m*n grid of numbers {0, 1} (cell (x, y) is 1 if there is a mine in cell (x, y)).
    
    
    Input
    First line of the input contains two space separated integers, m and n. Next m lines, each line has n numbers in {0, 1, 2, 3, 4, 5, 6 ,7 ,8}.
    Grid of mines?-mine-inp-png
    Output 
    A grid of numbers {0, 1}
    Grid of mines?-mine-out-png
    Any ideas about this (algorithm or code)?? thanks in advance.
    P/s: sorry for my poor English.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Did you make any attempt to do it yourself?
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    Registered User
    Join Date
    Aug 2014
    Posts
    2
    It's an excercise in my book. I've tried to do this with backtracking algorithm. But it seems so hard to me.

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by Dieuts Dieu View Post
    But it seems so hard to me.
    If it wasn't hard, you wouldn't learn anything. You could post your code, like the forum guidelines tell you to, and you should ask specific questions about the things that are giving you trouble.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  5. #5
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    I honestly don't know if there's enough information in the description to solve the problem on anything but a conceptual level, maybe not enough for that.

    For an instance of missing details, how much information is the algorithm allowed to glean from the container initially? How much information does the algorithm obtain when it makes a choice, just the number of the point it has chosen, or surrounding points as well?

    Another interesting thing is that the mines are represented with a number 1, are there no cells that have only 1 bomb next to them (seems like a dangerous neighborhood :P) ?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with the grid
    By wannabec++ in forum C++ Programming
    Replies: 2
    Last Post: 12-05-2010, 02:43 PM
  2. Can't see mines or any others Profile!
    By George M. in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 09-19-2008, 12:41 PM
  3. Land Mines
    By vasanth in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 02-19-2003, 12:00 PM