solve a simple puzzle w java