Center-symmetric pattern

Jan 27, 2010 at 4:03pm
Hey guys, I have a problem about programming one excercise. Here's the thing: I have to find which continuous largest, center-symmetric pattern can be insert into the specified area (area will be rectangular or square map, walls are signed by '#', free boxes are signed by ' '(space), boxes occupied by pattern are signed by 'o'). Width and height of map can be also odd or even and the point of symmetry can be out of image (for example, circle). Pattern will never touch the wall, even with a corner and also pattern boxes have to touch each other with a side, no corner. For one map there can be few possible maximum patterns, so I will choose an arbitrary of them.
Examples (input -> output):
Example1:

#########    #########
#       #    #       #
#   #   # -> # o #   #
#       #    #       #
#########    #########


Example2:(cannot create any pattern)

####    ####
#  # -> #  #
####    ####


Example3:

##     ##    ## ooo ##
#       #    #  ooo  #
#       #    # ooooo #
#       # -> #  ooo  #
#       #    #  ooo  #
#       #    #       #
#########    #########


Example4:

##########    ##########
#    #####    #    #####
#     ####    # oo  ####
#      ###    # ooo  ###
#       ##    #  ooo  ##
##       # -> ##  ooo  #
###      #    ###  ooo #
#        #    #     oo #
#        #    #        #
#     ####    #     ####
##########    ##########


I want to store a map in 2D vector structure and I think the algorithm should start find a pattern for all possible points of symmetry (for all free boxes) and choose the maximum one. I can't find a way how to do this. I hope it's comprehensible and we find a solution :-) I will really appreciate your help.
Topic archived. No new replies allowed.