Solution (source code)

= Solution

Given $Z_i=n$, the probability of no friendship among people sharing day $i$ is $2^{-n(n-1)/2}$. The day counts are independent, so
$$
\boxed{\mathbb P(\text{no matching friend pair})
=\left[
 e^{-1}\sum_{n=0}^\infty\frac{2^{-n(n-1)/2}}{n!}
\right]^{365}
=\left(\frac{2+C}{e}\right)^{365}.}
$$