Narlblog Nothing here, promised

SAT solver for AYTO

April 20, 2026 · 3 min read

parallelized constraint SAT solver designed specific for the reality television show Are You The One? (AYTO)

mathtrash tvayto

Mathematical Formulation of the AYTO Solver

Constraint Satisfaction & Surjective Bipartite Matching

1. Variables and Sets

Let G1G_{1} be the first group (e.g., group 1 candidates) of size NN, and G2G_{2} be the second group (e.g., group 2 candidates) of size MM, where NMN \le M.

  • The algorithm seeks to find all valid mappings between the two groups.
  • Mathematically, it searches for all valid surjective functions f:G2G1f: G_{2} \rightarrow G_{1}.
  • Surjectivity implies that every person in G1G_{1} must be matched with at least one person in G2G_{2}.

2. Constraints

The function ff must satisfy two primary types of constraints:

2.1. Allowed Mappings (Truth Booths)

Let A(y)G1A(y) \subseteq G_{1} represent the set of allowed matches for a given yG2y \in G_{2}. Initially, A(y)=G1A(y) = G_{1} for all yy. The "Truth Booths" apply absolute constraints:

  • Confirmed Match (True): If (x,y)(x,y) is a confirmed match, then A(y)={x}A(y) = \{x\}.
  • Confirmed Non-Match (False): If (x,y)(x,y) is a confirmed non-match, then A(y)=A(y){x}A(y) = A(y) \setminus \{x\}.

In the implementation, A(y)A(y) is efficiently represented as an NN-bit integer, where the ii-th bit is 1 if xiA(y)x_{i} \in A(y), and 0 otherwise.

2.2. Ceremony Constraints

Let CC be the set of all ceremonies. Each ceremony cCc \in C consists of a set of guessed pairs PcG1×G2P_{c} \subset G_{1} \times G_{2} and a score bcNb_{c} \in \mathbb{N} (the "beams"), representing the exact number of correct matches in that guess.

For every ceremony cCc \in C, a valid function ff must satisfy:

(x,y)PcI(f(y)=x)=bc\sum_{(x,y)\in P_{c}}\mathbb{I}(f(y)=x)=b_{c}

where I\mathbb{I} is the indicator function that equals 1 if the condition is true and 0 otherwise.


3. Search Space and Pruning

The algorithm explores the search space using a Depth-First Search (DFS) tree, building the function ff sequentially. Let fkf_{k} be a partial assignment of the first kk elements of G2G_{2}.

Pruning by the Pigeonhole Principle: At depth kk, let UkG1U_{k} \subseteq G_{1} be the set of elements in G1G_{1} that have already been assigned a match.

  • The number of elements in G1G_{1} still needing an assignment is NUkN - |U_{k}|.
  • The number of unassigned elements in G2G_{2} is MkM - k.

Because the final function ff must be surjective, if the number of required assignments is greater than the number of available slots, the branch is physically impossible and is pruned immediately:

NUk>MkPrune branchN - |U_{k}| > M - k \Rightarrow \text{Prune branch}


4. Objective

Let F\mathcal{F} be the set of all fully assigned, valid functions ff that survive the pruning and satisfy all ceremony constraints. The algorithm outputs two standard metrics:

  1. Total Possibilities: FF
  2. Marginal Probabilities: A matrix P[0,1]N×MP \in [0,1]^{N \times M}, representing the likelihood of each specific pairing across all valid universes.

For each xiG1x_{i} \in G_{1} and yjG2y_{j} \in G_{2}, the probability is calculated as the ratio of valid functions that contain that specific match over the total number of valid functions:

Pi,j=1FfFI(f(yj)=xi)P_{i,j}=\frac{1}{|\mathcal{F}|}\sum_{f\in\mathcal{F}}\mathbb{I}(f(y_{j})=x_{i})

Rust Implementation

Here is an example implementation in Rust: AYTO-Solver

screenshot-2026-05-18-at-14-23-10-ayto-match-rechner-themed-edition.png
screenshot-2026-05-18-at-14-23-10-ayto-match-rechner-themed-edition.png