The way I see it, you have 3 options:
- Come up with a data structure that maps combinations of bad tiles to tiles that should replace them.
- Tweak your generator so it doesn't generate bad tiles in the first place.
- Create sprites for the bad tiles so there aren't any bad tiles anymore.
Which option are you trying to do?
It seems like you're going for option 1. How are you representing the underlying data that tells you which tiles to draw?
Keep in mind that there might be an extremely large number of possible bad combinations, in which case option 2 or even option 3 might end up being less work.
As always, the answer is to break your problem down into smaller steps.
Can you write a function that takes a 2D array (or whatever) that represents a bad combination and returns whether that can be found in the data structure (is it another 2D array?) that represents your whole map?
Can you modify that function to return the position of the bad combination?
Can you write another function that takes a 2D array (or whatever) that represents a GOOD combination, as well as a position, and inserts that combination into the whole map at that position?
Once you have those functions working, then you can combine them in another method that loops through all of the bad combinations and tries to replace them.