4. Among the positive integers less than 20, each time three numbers are taken without repetition, so that their sum is divisible by 3. Then the number of different ways to do this is $\qquad$ .
4.327.

Divide these 19 numbers into three categories based on the remainder when divided by 3:
$$
\begin{array}{l}
A_{1}: 3,6,9,12,15,18 ; \\
A_{2}: 2,5,8,11,14,17 ; \\
A_{3}: 1,4,7,10,13,16,19 .
\end{array}
$$

Thus, the number of ways to satisfy the conditions of the problem are only four scenarios.
(1) Choose any three numbers from $A_{1}$, there are $\mathrm{C}_{6}^{3}=20$ ways;
(2) Choose any three numbers from $A_{2}$, there are $\mathrm{C}_{6}^{3}=20$ ways;
(3) Choose any two numbers from $A_{3}$, there are $\mathrm{C}_{7}^{3}=35$ ways;
(4) Choose one number from each of $A_{1}$, $A_{2}$, and $A_{3}$, there are
$$
6 \times 6 \times 7=252
$$

ways.
Therefore, the total number of ways is
$$
20 \times 2+35+252=327 \text { (ways). }
$$