Just found Karnaugh Maps interesting so I'm throwing some code at it. http://en.wikipedia.org/wiki/Karnaugh_map