Forty-two cubes with 1 cm edges are glued together to form a solid rectangular block. If the perimeter of the base of the block is 18 cm, then the height, in cm, is

$\textbf{(A)}\ 1 \qquad \textbf{(B)}\ 2 \qquad \textbf{(C)}\ \dfrac{7}{3} \qquad \textbf{(D)}\ 3 \qquad \textbf{(E)}\ 4$
1. Let the dimensions of the rectangular block be \( l \times w \times h \), where \( l \) is the length, \( w \) is the width, and \( h \) is the height.
2. The volume of the block is given by the product of its dimensions:
   \[
   l \times w \times h = 42 \text{ cubic centimeters}
   \]
3. The perimeter of the base of the block is given as 18 cm. The base of the block is a rectangle with dimensions \( l \) and \( w \). Therefore, the perimeter \( P \) of the base is:
   \[
   P = 2l + 2w = 18 \implies l + w = 9
   \]
4. We need to find integer values for \( l \) and \( w \) such that their product with \( h \) equals 42. We can use the equation \( l + w = 9 \) to find possible pairs of \( l \) and \( w \):
   - If \( l = 7 \) and \( w = 2 \):
     \[
     l \times w \times h = 7 \times 2 \times h = 42 \implies 14h = 42 \implies h = 3
     \]
   - If \( l = 6 \) and \( w = 3 \):
     \[
     l \times w \times h = 6 \times 3 \times h = 42 \implies 18h = 42 \implies h = \frac{42}{18} = \frac{7}{3}
     \]
   - If \( l = 5 \) and \( w = 4 \):
     \[
     l \times w \times h = 5 \times 4 \times h = 42 \implies 20h = 42 \implies h = \frac{42}{20} = 2.1 \quad (\text{not an integer})
     \]

5. From the above calculations, the only integer solution for \( h \) is when \( l = 7 \) and \( w = 2 \), giving \( h = 3 \).

The final answer is \(\boxed{3}\).