A modular tile puzzle

Invert the Matrix

Campaign

Campaign

Custom Level

Custom Level

Grid Size

States

Tap Pattern

Difficulty

Extras

Playground

Playground

States3 states
Tap PatternCross
Grid Size5x5
Puzzle CodeShare

Daily

Daily Challenges

Campaign

Level

Taps 0
Time 0:00
Personal Best -

Guide

How to Play

Clear every tile by turning it white. Tapping a tile applies its tap pattern to the board, and every tile reached by that tap advances by one state.

Use previews and level clues to plan calmly before each tap.

1. Make every tile white

  • A white tile is solved.
  • Colored tiles are not wrong. They just need to keep advancing until they return to white.
  • The puzzle ends only when every tile is white at the same time.

2. Tap and cycle

  • Tap an available tile to apply the level's tap pattern.
  • Every tile reached by the pattern advances one state.
  • States cycle: after the last colored state, the next advance returns that tile to white.

3. Use the pattern preview

  • A level can use a cross, diagonal, square, horizontal, vertical, knight, or mixed pattern.
  • Hold or hover a tile to see exactly which tiles will change before you tap.

4. Handle special tiles

  • A tile with a lock icon still needs to become white and can change when a nearby tap reaches it.
  • You cannot tap a tile with a lock icon directly.
  • An empty hole is outside the board. Tap patterns skip empty holes.

Modes

Choose your puzzle

  • Campaign: Pick groups on a 5x5 map. Earn 15 stars in a group to open adjacent groups.
  • Custom Level: Choose board size, states, pattern, difficulty, tiles with lock icons, and empty holes. The generator always prefers a unique solution.
  • Playground: Build a board by hand, share its puzzle code, and play without a completion modal.
  • Daily Challenge: Play the same three generated puzzles as everyone else for the date. Each puzzle keeps its own saved best score.

Taps, stars, and hints

  • The tap counter counts every tap you commit.
  • Three stars mean you matched the generator's minimum found tap count.
  • Two-star and one-star targets allow extra taps.
  • Undo rewinds one tap, and Reset restores the starting board.
  • Hint applies the next tap from a solver plan. A hinted try can still complete the puzzle, but it no longer earns stars.
  • Tiles changed by a hint are outlined in red.

Settings

  • Sound toggles audio effects.
  • Show numbers on tiles displays state values when you want a more exact view.
  • Android also includes haptic feedback controls.

Guide

The Math

Invert the Matrix is a modular linear-algebra puzzle.

To play, think of each tile as having a state, shown by its color. A tap on a tile does not change only that tile, but every tile in a pattern centered on the chosen tile. After the last state, or color, a tile returns to white. The goal is to find a sequence of taps that makes all tiles white at the same time. Some boards have only two possible states: white and blue, and only one pattern: a cross centered on the tile you tap. But later on, everything gets much more complicated.

Modeling the game

Turn the board into one equation

To model a level, first list the active board positions in a fixed order. Once that list is fixed, a displayed board becomes a vector \(s\in R^m\). Here \(R=\mathbb Z/n\mathbb Z\) means values are read modulo \(n\), \(n\) is the number of tile states, and \(m\) is the number of active positions.

Each allowed tap has an effect vector in \(R^m\). For a tappable position \(q_j\), the vector \(v_j\) has value \(1\) exactly at the active positions advanced by that tap, and \(0\) elsewhere. The matrix \(A\) is built by placing these effect vectors as its columns. A tap-count vector \(x\in R^r\) records how many times each allowed tap is used, modulo \(n\), and solving means choosing \(x\) with \(s+Ax=0\).

All arithmetic is performed modulo \(n\), so the value after \(n-1\) is \(0\). Prime state counts such as \(2,3,\) and \(5\) give finite fields, where every value different from \(0\) has a multiplicative inverse. The four-state mode uses the ring \(\mathbb Z/4\mathbb Z\), where some values different from \(0\) cannot be used for division.

\[ A x \equiv -s \pmod n \]

From Lights Out

The same question, in modular form

In ordinary Lights Out, every tile is either \(0\) or \(1\). Tapping a tile changes the same shape of tiles around it every time, usually the tapped tile plus the tiles directly above, below, left, and right. Changing a tile is adding \(1\) modulo \(2\), so tapping the same tile twice gives no net change. This is the simplest version of adding tap effects together.

This game keeps that add-the-effects rule while allowing \(n\) states, so values are read in \(R=\mathbb Z/n\mathbb Z\). Empty holes are not included in the board vector. Tiles with lock icons stay in the board vector because they must become white, but they do not get tap choices. Tap patterns determine the columns of \(A\).

The mathematical question is precise: can the allowed taps add up to the target change \(-s\)?

1. The board is a vector

Let \(P=\{p_1,\ldots,p_m\}\) be the list of active board positions, in a fixed order. A configuration is the vector \(s=(s_1,\ldots,s_m)\in R^m\), where \(s_i\) is the state value shown on tile \(p_i\), read modulo \(n\). The solved board is the zero vector \(0\in R^m\).

\[ s=(s_1,\ldots,s_m),\qquad s_i\in \mathbb Z/n\mathbb Z \]

2. Every allowed tap has an effect vector

Let \(q_1,\ldots,q_r\) be the positions that can be tapped. The effect vector of the tap at \(q_j\) is \(v_j\in R^m\). Its \(i\)-th value is \(1\) when that tap advances tile \(p_i\), and \(0\) otherwise. The tap matrix is \(A=[v_1\ \cdots\ v_r]\), so the \(j\)-th column of \(A\) is \(v_j\).

In the matrix, a row tracks a board position and a column tracks an allowed tap. A tile with a lock icon still gets a row because its value must become zero, and nearby taps may change it. It does not get a column because it cannot be tapped directly.

\[ (v_j)_i= \begin{cases} 1 & \text{the tap at }q_j\text{ advances }p_i,\\ 0 & \text{otherwise.} \end{cases} \]

Goal

Find a tap-count vector

A tap-count vector is an element \(x=(x_1,\ldots,x_r)\in R^r\). Its coordinate \(x_j\) counts how many times the tap at \(q_j\) is used, modulo \(n\). Executing \(x\) adds \(\sum_j x_jv_j=Ax\) to the board. Thus tap order is irrelevant to the algebra. Only each tap count modulo \(n\) matters.

After applying the plan, the board is \(s+Ax\). Solving the puzzle means making this vector equal to the zero vector, equivalently solving \(Ax\equiv -s\pmod n\).

\[ s + A x \equiv 0 \pmod n \] \[ A x \equiv -s \pmod n \]

When does a solution exist?

The columns of \(A\) generate the set of all board changes obtainable by allowed taps. Call this set the image of \(A\), written \(\operatorname{Im}(A)=\{Ax:x\in R^r\}\). A solution exists exactly when the target vector \(-s\) is in that set.

\[ \text{solution exists} \Longleftrightarrow -s\in \operatorname{Im}(A) \]

Over a field, such as \(\mathbb F_2,\mathbb F_3,\mathbb F_5\), this can be checked by simplifying the rows of the system \([A\mid -s]\). A row of the form \([0\ \cdots\ 0\mid c]\), where \(c\) is not \(0\), proves that no solution exists. If no such row appears, the simplified system gives at least one tap plan.

What changes for non-prime \(n\)?

For composite \(n\), \(\mathbb Z/n\mathbb Z\) is a ring but not a field. You may add and multiply as usual, but division is valid only by values with a multiplicative inverse. For \(n=4\), the value \(2\) is different from \(0\) and has no inverse: no value \(a\) satisfies \(2a\equiv 1\pmod 4\).

\[ 2a\not\equiv 1\pmod 4 \]

The rule does not change: there is still a solution exactly when \(-s\) is in \(\operatorname{Im}(A)\), but the check must respect ring arithmetic. Row operations that divide by values with no inverse are not valid. For larger composite \(n\), the check can be split into smaller modulo checks that must all agree.

When is the solution unique?

If \(x_0\) is one solution, then every other solution is \(x_0+z\), where \(z\in R^r\) is a tap-count vector with \(Az=0\). The equation \(Az=0\) means that using the taps in \(z\) causes no net change on the board. The set of all such \(z\) is the kernel of the tap matrix, written \(\ker(A)\).

\[ \{x\in R^r:\ Ax=-s\}=x_0+\ker(A) \]

Tap counts already live modulo \(n\), so tapping one tile \(n\) additional times adds \(n e_j=0\), the zero vector in \(R^r\). That represents the same tap-count vector, not a new tap-count solution.

Uniqueness fails exactly when there is a tap-count vector \(z\ne 0\), meaning \(z\) is not the zero vector, with \(Az=0\). In that case \(x_0\) and \(x_0+z\) are distinct tap-count vectors that solve the same board. Thus the solution as a tap-count vector is unique precisely when \(\ker(A)=\{0\}\). Over fields this is equivalent to saying that no combination using at least one allowed tap adds the effect vectors to zero. Over rings, the same kernel condition is the correct statement over \(\mathbb Z/n\mathbb Z\).

When is \(A\) invertible?

A true inverse matrix can exist only when \(A\) is square, meaning it has the same number of rows and columns. This happens on a \(w\times h\) board with no tiles with lock icons and no empty holes, when there is exactly one allowed tap for each tile. In that case \(A\) sends vectors in \(R^{wh}\) to vectors in \(R^{wh}\), and invertibility means every starting board has one unique tap-count solution.

\[ \exists\, A^{-1} \Longleftrightarrow \det A\in R^\times \]

Equivalently, \(\det A\) must have a multiplicative inverse modulo \(n\). For prime state counts \(n=2,3,5\), this means \(\det A\not\equiv0\pmod n\). Equivalently, simplifying rows can choose a value different from \(0\) in every column. For \(n=4\), it means \(\det A\) is odd. If this fails in the square case, some board vectors are unreachable and some tap-count vectors different from zero lie in \(\ker(A)\). With tiles with lock icons or empty holes, \(A\) may have different numbers of rows and columns. Then the useful tests are whether the target change is reachable and whether \(\ker(A)\) contains tap-count vectors different from zero.

Why the minimum matters

If there are several tap-count solutions, the game can still ask for the most efficient one. For each tap count \(x_j\in R\), choose the number \(\tilde{x}_j\in\{0,\ldots,n-1\}\) that represents it. The physical length of a plan is \(\ell(x)=\sum_j\tilde{x}_j\), and the star target is based on a solution with minimal length among the solutions found.

\[ \ell(x)=\sum_j \tilde{x}_j, \qquad \tilde{x}_j\in\{0,\ldots,n-1\} \]

How the shortest solver works

For small boards the app searches by tap count: first boards one tap away, then two taps away, and so on. The first time it reaches the zero board, that number is the true minimum number of physical taps.

For larger boards with prime state counts \(n=2,3,5\), it simplifies the rows of \(Ax=-s\). If the simplified system leaves choices that are not forced, the solutions are \(x_0+\ker(A)\). When the search over those extra tap-count vectors is small enough, the app enumerates them and chooses the one minimizing \(\ell(x)\). If that exact search is too large, or \(n\) is composite and the board is too large for that search, the game falls back to a known solving plan instead of claiming a proof of minimality.

The shortest tap-count vector is not necessarily unique. Distinct solutions can tie for the same \(\ell(x)\), and a single vector can be played in many tap orders. The app keeps the same shortest plan every time when it can prove the minimum. It does not currently mark whether all shortest plans are unique.

Tiles with lock icons and empty holes

A tile with a lock icon stays in the board vector because its value must become zero, and nearby taps may still change it. It does not get its own tap choice in \(x\) because it cannot be tapped directly. An empty hole is left out of the ordered list \(P\), so the equation only tracks active board positions. This is how the same equation adapts to irregular boards.

How the generator uses this

The generator uses the same ingredients: board shape, tiles with lock icons, empty holes, tap pattern, and effect vectors. It chooses or verifies a starting vector \(s\) together with a tap-count vector \(x\) satisfying \(s+Ax=0\). When the exact solver is available, it searches the solution set for a short tap-count vector so the star thresholds have a mathematical basis. Hints use a stored plan one tap at a time.

What the symbols mean
\(n\)
The number of tile states and the modulus used by the level. The app uses \(2,3,4,\) or \(5\) states.
\(s\)
The current board configuration as a vector in \(R^m\).
\(A\)
The tap matrix. Its \(j\)-th column is the effect vector \(v_j\) of the allowed tap at \(q_j\).
\(x\)
The tap-count vector in \(R^r\). Its coordinate \(x_j\) counts how many times the tap at \(q_j\) is used modulo \(n\).
\(\operatorname{Im}(A)\)
All board-change vectors obtainable by allowed taps.
\(\ker(A)\)
Tap-count vectors that produce zero board change.

Options

Settings

About

About

Version 1.0.9

Changelog

    pportilla