An Occasional Coding Exercise Leads To Puzzle Book Sales
There was a time back in my early Amazon career, when I was managing the Independent Publisher Portal, also known as Kindle Direct Publishing, that I wanted to end to end test the publishing process. The challenge with doing so was that the publishing workflows were really good at recognizing duplicative content as part of its fraud detection. This made testing repeatedly close to impossible, because each test required a new, unique book.
I decided to pop open Visual Studio, fire up my rusty C# skill, leverage Microsoft Word’s XML based formatting, and write some code to automatically generate books. Because I wanted them to be legitimate, repeatable, and make it to the Amazon marketplace, I couldn’t just randomly generate text files.
So I wrote a program that automatically generated Sudoku puzzles. First, I wrote a randomizer that would generate a random 9×9 sudoku grid filled with a solved and valid result. Then I wrote a sudoku solver to validate that the puzzle in its final form had a solution.
I then decided I wanted to have three different levels of solvable sudokus, with about 30 of each in a book. So, for each level, I removed a certain number of random digits from the puzzle, one by one, until the solver determined that the puzzle was no longer solvable. I then stepped back to the last solvable version and marked that as a “hard” puzzle, added two more digits back for a “medium”, and then two more digits back for an “easy” puzzle.
With that code written, I went online and downloaded a free use sudoku puzzle image, and created a Word document template including the cover file. I saved that file so I could open it later, along with a few fields I could merge in, such as the volume number, as well as the colors for the cover so any books I created could be unique. With that, a few parameters could be passed in to my program, generate 60 puzzles, add them as pages to the Word document, and save out a new, unique puzzle book.
I was able to successfully test my publishing workflow. Ten of these puzzle books were published out to Amazon. They remain available for sale today, and I still occasionally sell one.

With that done, I decided to go back and write a different puzzle output, adding a dictionary integration and code that created word search puzzles. There are ten of those out at Amazon as well. It was a fun little project that took a bit of thinking to get through, and over the course of several years managed to pay for a couple of dinners.
