puzzle logic