Scramble With Friends solver in PHP