My solution (but still with rejection in small dataset): - In every solution, the empty cells could be moved to touch a side (that is, if the empty cells is an "internal island", the same solution could be moved to have an empty cell on a side "touching" the exterior)
- Find a rectangle r x c, so empty cells == r x c or empty cells > r x c + 1 - Put the empty rectangle with one corner in the board corner, named A. - Cleverly extend the rectangle, if needed, to have n cells, where n = empty cells - Click on the corner A My code https://github.com/ajlopez/TddRocks/tree/master/Gcj2014 https://github.com/ajlopez/TddRocks/tree/master/Gcj2014/Minesweeper I put the empty rectangle at top left. The only problem with such approach, the extending phase should contemplate extending to the right, and extending to the bottom. I'm not sure if I can find the "biggest or more appropiate" initial rectangle that can be extended only to the right. Angel "Java" Lopez @ajlopez On Sun, Apr 13, 2014 at 3:20 AM, Mohamed Ghoneim <[email protected]>wrote: > This is wrong because of the last empty cell in the first column will > never get filled as there is no 0 surrounding it. > > -- > Mohamed Sayed Ghoneim > > > On Sun, Apr 13, 2014 at 8:18 AM, Dhruva Sagar <[email protected]>wrote: > >> I get the following : >> ***** >> ....* >> c...* >> ....* >> .**** >> >> >> On Sun, Apr 13, 2014 at 11:07 AM, Mohamed Ghoneim >> <[email protected]>wrote: >> >>> What will you output for 5 5 12 ? >>> >>> -- >>> Mohamed Sayed Ghoneim >>> >>> >>> On Sun, Apr 13, 2014 at 7:32 AM, Dhruva Sagar <[email protected]>wrote: >>> >>>> The problem does not state anything about placing the mines so I >>>> assumed we are free to choose that to try and get the optimal result. >>>> >>>> I decided to go with a spiral algorithm to place the mines until M >>>> mines are placed, from there I went ahead to calculate the weights for each >>>> of the remaining cells based on how many neighbors have mines and I >>>> selected the first mine with weight 0 as 'c' if present, if not then the >>>> answer would be impossible. >>>> >>>> However my answer seems to be rejected so if someone would be kind >>>> enough to throw some light on what I might be doing wrong it would be >>>> great! >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Google Code Jam" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> >>>> To post to this group, send email to [email protected]. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/google-code/898c6f4b-1dca-499c-9af4-78126f3fe5f0%40googlegroups.com >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >>> You received this message because you are subscribed to a topic in the >>> Google Groups "Google Code Jam" group. >>> To unsubscribe from this topic, visit >>> https://groups.google.com/d/topic/google-code/u8Zlclt-W6k/unsubscribe. >>> To unsubscribe from this group and all its topics, send an email to >>> [email protected]. >>> >>> To post to this group, send email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/google-code/CAGihN_kNuj3QfgXG9N4mxyXWgngr%2BrV3tkneHgJinq86D3L-Kg%40mail.gmail.com<https://groups.google.com/d/msgid/google-code/CAGihN_kNuj3QfgXG9N4mxyXWgngr%2BrV3tkneHgJinq86D3L-Kg%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Thanks & Regards, >> Dhruva Sagar <http://dhruvasagar.net> >> >> - g-talk : [email protected] >> - y! : [email protected] >> - github : github.com/dhruvasagar >> - work : dhruva.sagar@ac >> <[email protected]>tivesphere.com<[email protected]> >> >> ---------------------------- >> Senior Ruby/Rails/Node.js Consultant >> ActiveSphere <http://www.activesphere.com/> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google Code Jam" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/google-code/CAAJXOCCN4B_2b1Pa1%2B8fLS5E0L%2BG0hoW3KrY-HGtXrY%3Dm4AzRw%40mail.gmail.com<https://groups.google.com/d/msgid/google-code/CAAJXOCCN4B_2b1Pa1%2B8fLS5E0L%2BG0hoW3KrY-HGtXrY%3Dm4AzRw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "Google Code Jam" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/google-code/CAGihN_njrX__VDiJ7y3OTBSmSce%3DPzs5AK0ee_9n9nL36vOc4g%40mail.gmail.com<https://groups.google.com/d/msgid/google-code/CAGihN_njrX__VDiJ7y3OTBSmSce%3DPzs5AK0ee_9n9nL36vOc4g%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/google-code/CAMs%2BDqKQW9Sw6ehUDC06gigYACkW7hqPv6XhQVAVC3-4O%2Bto-Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
