There is no solution to the 51% attack problem.
However, don't worry as it is difficult to pull off a 51% attack. Like hacking the Federal Reserve.
I think the only reason no one has done that is because there are laws against it. If for example it was perfectly legal to do that, then it would have already been done numerous times.
There aren't any laws protecting Bitcoin however and there's a large number of tech savvy users.