Implementing a snake solver