Expanding on Mariano's answer: to get a formula for a truth table that has exactly one t
and the rest of the lines are f
, look at the line and write down the values of the variables in that line. For instance, if you wanted a formula for a truth table with three variables as in your second example which has a t
in the third line (corresponding to $X$ and $Z$ true, and $Y$ false) and f
in all the other ones, then since that line is "$X$ is true, $Y$ is false, and $Z$ is true", then you use the formula $X \wedge (\neg Y)\wedge Z$.
Now, suppose you have a formula with t
's in two rows and f
s everywhere else. Say, three variables, a t
in row three, a t
in row five, and f
's everywhere else. A formula that has a t
in just row three is, as before, $X\wedge (\neg Y)\wedge Z$. A formula that has a t
in just row five is $(\neg X)\wedge (\neg Y)\wedge Z$. So a formula that as a t
in just row three or row five is:
$$\Bigl( X\wedge (\neg Y)\wedge Z\Bigr) \vee \Bigl((\neg X)\wedge (\neg Y)\wedge Z\Bigr).$$
For an arbitrary number of t
's, just take the disjunction of enough formulas, each of which corresponds to a table with just one t
.