Implement Snail Algorithm.