refactoring move toString to puzzle