A algorithm for the Greep competition.