6. Find the number of matrices that satisfy two conditions:
3) the matrix has the form $\left(\begin{array}{lll}1 & * & * \\ * & 1 & * \\ * & * & 1\end{array}\right)$, where each * can take the value 0 or 1 and the rows of the matrix do not repeat.
Solution: Let $A$ be the set of matrices satisfying condition 1) and $B$ be the subset of $A$ consisting of matrices satisfying condition 2). We need to find the number of elements in the set $B$. Let $A_{ij}, i, j \in\{1,2,3\}, i \neq j$, be the subset of $A$ consisting of matrices in which row $i$ and $j$ are the same. Then $B=A \backslash\left(A_{12} \cup A_{23} \cup A_{13}\right)$ and $|B|=|A|-\left|A_{12} \cup A_{23} \cup A_{13}\right|$. The cardinality $\left|A_{12} \cup A_{23} \cup A_{13}\right|$ is conveniently calculated using the inclusion-exclusion principle:

$\left|A_{12} \cup A_{23} \cup A_{13}\right|=\left|A_{12}\right|+\left|A_{23}\right|+\left|A_{13}\right|-\left|A_{12} \cap A_{23}\right|-\left|A_{13} \cap A_{23}\right|-\left|A_{12} \cap A_{13}\right|+\left|A_{12} \cap A_{23} \cap A_{13}\right|$.

It is easy to calculate the cardinalities of the sets involved in this expression:

$$
\left|A_{12}\right|=\left|A_{23}\right|=\left|A_{13}\right|=2^{3},\left|A_{12} \cap A_{23}\right|=\left|A_{13} \cap A_{23}\right|=\left|A_{12} \cap A_{13}\right|=\left|A_{12} \cap A_{23} \cap A_{13}\right|=1
$$

We get $|B|=2^{6}-3 \cdot 2^{3}+3-1=42$.