puzzle() loops till it generates a valid puzzle