Question: For every subset $T$ of $U = \{ 1,2,3,\ldots,18 \}$, let $s(T)$ be the sum of the
elements of $T$, with $s(\emptyset)$ defined to be $0$. If $T$ is chosen at random
among all subsets of $U$, the probability that $s(T)$ is divisible by $3$ is
$\frac{m}{n}$, where $m$ and $n$ are relatively prime positive integers. Find $m$
my attempt:
there will be $2^{18}$ subsets in total
and there 6 numbers which are multiple of $3 $,
$6$ numbers are giving remainder 1
when divided by 3,
6 numbers are giving remainder 2 when divided by 3
first i counted subsets of size $1$ such that it's sum is divisible by 3 which
is 6
then, similarly numbers of subset of size $2$ such that its sum is divisible by 3 is $^6 C_1.^6 C_1=36$
similarly numbers of subset of size $3$ such that its sum is divisible by 3 is $216$
but i find difficult to count this way when size of subset increases (say above 10).
in my book solution is provided using Generating function which i do not
understand.so, i want to ask how to derive the expression for generating function in these kind of questions rest i can do myself (finding coefficient of suitable power of 'x')
Thank you.