What I have.
A simple subdivided Cube with circular holes in it - every side, six of 'em. Holes have they own material, and each of the hole has different color. Holes are completely flat.
I have managed to color them dumb way (in other words - my way) by separating XYZ and assigning pairs of colors to opposite sides. Not to shabby. It's working after all and working well, I reckon. But... Only for this particular example.
What I want.
I would want to achieve the same result (similar, but this I'll explain later), with one Color Ramp and math-node-vector-fu so the color would be assigned based on Normal direction. Randomly or not, it's not so important, as far as every hole/face group would have different color - providing same number of colors in ramp as there are holes.
And a little catch.
It would be nice if it will be possible to use it on more face groups and with different angles.
What I've tried.
To be honest. Many things. I've tried to use Normal Coordinates mixed and added and crossed with other ones. I've tried to use multiple setups from different sources regarding "different color for faces". I've multiplied the hell out of it. Nothing worked. The best try was to have 3x3 different colors (3x reds, 3x blues).
Disclaimer: I would rather avoid Python scripting, Vertex Painting, UV Unwrapping, Texture Painting, assigning materials by hand for each face group and 3rd party add-ons. This whole question is about understanding Cycles more and pushing it to limits.
Master build or 2.8 branch answers are welcome.
Blend file for testing:
Result from Ed Tate answer: