  It is known that for any smooth periodic function $f$ the sequence
$(f(2^kx))_{k\ge 1}$ behaves like a sequence of i.i.d.\ random variables, for
example, it satisfies the central limit theorem and the law of the iterated
logarithm. Recently Fukuyama showed that permuting $(f(2^kx))_{k\ge 1}$ can
ruin the validity of the law of the iterated logarithm, a very surprising
result. In this paper we present an optimal condition on $(n_k)_{k\ge 1}$,
formulated in terms of the number of solutions of certain Diophantine
equations, which ensures the validity of the law of the iterated logarithm for
any permutation of the sequence $(f(n_k x))_{k \geq 1}$. A similar result is
proved for the discrepancy of the sequence $(\{n_k x\})_{k \geq 1}$, where $\{
\cdot \}$ denotes fractional part.
