Cracking the Code: Creating NinjaPuzzles

Ever since becoming a Dad, I have enjoyed creating paper-based games and puzzles for my son. I began with mazes, starting with hand-drawn ones and later moving on to computer-generated ones. As he got older, he became interested in Sudokus, albeit the easier ones since he was only six years old at the time. More recently, he has discovered word searches and kriss-kross puzzles.

A screenshot of a maze I posted on Twitter

A screenshot of a maze I posted on Twitter

To make it easier for my son (and others) to access these puzzles, I decided to create a website to host them all. And that’s how NinjaPuzzles.com came into existence.

The Technology Behind NinjaPuzzles

NinjaPuzzles is a static website built using Jekyll as the content management system (CMS). To create the puzzles themselves, I use PHP scripts.

Mazes

The mazes on NinjaPuzzles are created using the same PHP script I used when publishing them on Twitter a couple of years ago. This script generates random mazes with various difficulty levels.

Word Searches

For word searches, I started with a PHP script that was generated by ChatGPT—an AI language model. However, I made significant modifications to this script to ensure more random layouts for the word search grids. The word lists for each puzzle are stored in text files.

To add new word searches to NinjaPuzzles, all I have to do is create a new file with the list of words and run the PHP script. It automatically generates the PDFs, images, and markdown content required for displaying the puzzle on the website.

Kriss-Kross Puzzles

Similar to word searches, kriss-kross puzzles were also created using a ChatGPT app as a starting point. Again, some modifications were necessary to achieve optimal designs that allow easy distinction between different word regions within the grid.

The hardest part to build was the design of the grid. Ensuring players could easily tell where the different words started and ended was a challenge that required a lot of trial and error. I’m pleased with the final design - I feel like it looks like it was the only possible layout, but it took a few attempts to get there.

Like the word searches the kriss-kross puzzles are generated using a PHP script. The word lists are stored in text files, and the script generates the PDFs, images, and markdown content for the website. Currently there’s only 5 kriss-kross puzzles on NinjaPuzzles, but I will be adding a lot more very soon.

Sudokus

Creating sudokus was the quickest process. The majority of the code for generating these puzzles was written by ChatGPT, with my main involvement being in the design aspect. To ensure solvability, I also developed a Javascript sudoku solver so that users can find the solutions.

However I also decided to create mini sudokus. These are sudokus that are on a 4x4 grid rather than the traditional 9x9 grid. Making these work was a bit more effort since I had to modify all of the hard coded properties from the original puzzle generator. Now that this has been done I should be able to easily add more types of sudokus in the future - maybe a 6x6 grid?

I also need to update the solver to work with the new size. Currently it only works with 9x9 sudokus.

Making Puzzle Downloads Quick and Consistent

To generate PDFs for puzzle downloads on NinjaPuzzles, I rely on MPDF — a PHP library that simplifies PDF creation. I have created generic templates and methods that enable quick and consistent designs for all of the puzzles.

Future Plans for NinjaPuzzles

NinjaPuzzles is still in its early stages, but I plan to continuously add new puzzle downloads to the website. My aim is to provide a variety of engaging and challenging puzzles for kids (and adults) to enjoy.


Creating NinjaPuzzles has been an exciting and rewarding journey so far. It allows me to combine my love for creating puzzles with my passion for web development. If you’re looking for fun and educational activities to keep your little ninjas entertained, be sure to check out NinjaPuzzles.com.

Stay tuned for more updates as I continue expanding the collection of brain-teasing adventures on NinjaPuzzles!

Let me know what you think on Mastodon, or BlueSky (or Twitter X if you must).

Link to this page

Thanks for reading. I'd really appreciate it if you'd link to this page if you mention it in your newsletter or on your blog.

Related Posts

28 Sep 2021

Creating Generative Art with PHP

These last few weeks I’ve been experimenting with Generative Art, using PHP. You can see the evolution of my latest series on Twitter. Generative Art is creating artworks through programming. Generative art has a few different names, Procedural art and...
21 Oct 2023

Creating Jekyll Plugins (and modern image formats)

When I first started in web design (in the late 90’s), there was a lot of emphasis on learning about file formats, file naming conventions, and other technical aspects that don’t seem to be talked about these days. It’s easy...
26 Mar 2021

Creating a Twitter Maze Bot

I recently had the idea to make a Twitter Emoji Maze bot, so I tweeted my idea and it was suggested I write a tutorial about how I made it. So I’m going to try to write the article as...
12 Jun 2023

Rebuilding the Binary Moon Website

I have recently rebuilt the Binary Moon website. It’s been something I’ve been thinking about for a while, and a recent issue with my web host pushed me to finally make a start. In this post, I’ll share some of...
23 Mar 2017

New Adventures in Jekyll

I use WordPress a lot, but a couple of weeks ago I decided to rebuild one of my older sites with Jekyll (a static site editor) so that I could host it on Github pages. As I have explained before...
18 Mar 2010

Realigning James Woodcock dot com

Recently I was talking to my friend, and fellow blogger James Woodcock, about his website and somehow I ended up suggesting I spend an hour or so tidying it up.James is a video game and tech journalist… and an endless...