solution to snakes and ladder problem.