|We are looking at a rectangular map. We just studied the
map and want to refold it like it was. We can see the foldlines and tell which
way they were folded. It looks something like this, where
each X represents a section of the map, and the letter between horizontally or
vertically adjacent sections tells whether the fold between the sections was up (i.e., the two sections
were folded so that the 2 visible sides went towards each other) or was down. The interior spaces
are where horizontal and vertical fold lines cross each other.
u u d d
Each section of the map is the same size rectangle as all the others, and when the
map is refolded all the sections will be on top of each
other. We want to know the minimum number of folds
Create a class MapFolder that contains a method minFolds that is given a
String theMap and returns the minimum number of folds required,
or -1 if it is not possible to refold theMap.
theMap only contains the orientation of the folds. So for the example map, it would