Crossmath Game

Crossmath

rustautodidactecurieux
Back to projects

Result

You can play this mathematical crossword to solve additions and subtractions!

To play, simply enter the values in the empty boxes. You can use the hints to help you. They give you the list of missing numbers.

Once you’re sure about what you’ve entered, press the “Validate” button to get the verdict (without the correction so you can try again).

Why?

In my third-year option, I have dedicated autonomous time to work on 2 types of projects: MON (2x10h periods where I can learn autonomously on a subject in computer science, project management or management); and POK (20h to complete a mini-project that allows me to demonstrate my knowledge). For this first period, I decided to learn Rust during my first 2 MON and create a website that uses webassembly for my first POK. I spent 20h and 26 minutes on this project (including time to discover webassembly).

Initially, for this project, all I knew was that I was going to write Rust, compile it to webassembly and then use this code in a website. The idea of making this mathematical “crossword” game came to me after my first tests. I had seen an advertisement for a mobile application with such a game, and I found the challenge interesting while remaining feasible within the timeframe.

The Challenges

After understanding what webassembly is and how to go from Rust to webassembly, I dove into the main subject: writing the game grid generation algorithm.

The program would work as follows: my webassembly generates the grids and the site displays them while allowing the player to interact with this grid. The grid generation algorithm must therefore create n equations randomly and place them in a grid. It then returns this grid after randomly removing numbers. To do this, I use an Equation struct, which contains 3 integers: x, y and z such that x + (or -) y = z. This equation also has a direction and orientation (from left to right, from top to bottom, etc…). The algorithm will then generate a grid with enough cells for the n equations to fit (100 * n² cells). It starts by placing a completely random equation in the middle of the grid. Then, it selects one of the numbers in the grid (let’s call it k), and creates a random equation in which k is one of the terms (or the result). Then, the algorithm will try to see in which direction and orientation it should insert said equation. If this direction and orientation doesn’t exist, it chooses another number present in the grid and starts again.

Each time the algorithm enters an equation into the grid, it adds in which direction and orientation it is inserted. It also keeps in memory a list of numbers present in the grid. These numbers are “available” if they are only associated with one equation in the grid.

Before returning the grid, the algorithm removes the cells that are useless.

What I Learned

This project allowed me to put into practice what I learned about Rust during my first two MON.

I was also able to discover WebAssembly, I find it quite fascinating!

Find the code for my project on my github.

Copyright © 2025