Testing our code for the XOR, OR and AND gates

Last week we discussed three different types of gates, the so-called XOR, the OR and the AND gates. Their inputs and outputs can be summarized using the following tables, first for the OR gate with inputs \( x_1 \) and \( x_2 \) and outputs \( y \):

\( x_1 \) \( x_2 \) \( y \)
0 0 0
0 1 1
1 0 1
1 1 1