Stuart’s MATLAB Videos

Watch and Learn

Puzzler: Rules of the new game

Posted by Doug Hull,

I was playing a game by LabPixies on my iPhone. I spent more time thinking about programming an optimal solution than anything else while playing. I decided to give it a try in MATLAB. After getting some help from the MATLAB community in the last puzzler I was able to implement a quick running solution.

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 (hull@mathworks.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.

0 views (last 30 days)  | |

Comments

To leave a comment, please click here to sign in to your MathWorks Account or create a new one.