I am always amazed at the creativity of the MATLAB community, so I am posting all the files needed so you can implement your own solution. I have included my solution also, but I recommend not looking until you have tried your own.
Since this is a more involved problem, posting to the comments does not seem as reasonable. Please e-mail me (email@example.com) your completed code (one file, has everything it needs to run, your contact info in the comments) and I will put together a video covering the best of ideas. If I use your code or ideas in the video, I will send you a MATLAB t-shirt.
MINOR SPOILER ALERT
What I have discovered is that this program either finds a solution very quickly, or does not find one before I get bored (5 minutes, I should run it overnight….). I take a “greedy” approach (selecting the color that will cause the largest change), this is not always optimal. I am doing an exhaustive search, only looking one move ahead. This will find a solution if it is possible, but there might be a better way.
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.