I didn't created this but I tried to model it so I could understand a little more how it works.
Each input can be at level L,H or Z but if none of them is Z, they must be different (I.e. LL and HH aren't permitted).
Weird things happen when you change the resistor value (there send to be a threshold that dramatically change things between 21 and 22 ohms). If you know why, feel free to leave a comment :-)
Also I couldn't find a better way to have tristate pins than using two switches for each. Please let me know if there is a better way.