## Problem Statement
Construct a circuit that, given an array `in` of 100 tuples and an arbitrary value `match`, returns:
- `num_match`: represents the number of elements within `in` where the first entry matches `match`.
- `out`: An array of 100 tuples. The beginning of this array consists of tuples from `in` that satisfy the` match` condition. Any remaining entries, after all the matching tuples, are 0-padded.
The objective is to design the circuit in a way that minimizes the number of non-linear constraints.
<a href="https://gist.github.com/enricobottazzi/1687b3393262984ed9c46f8146e5ae90">
<img src="https://hackmd.io/_uploads/BJ1-F1Wjh.png" width="50px" alt="GitHub">
</a>
## Approach
The given problem can be divided into two main tasks:
1. Identify the indexes of the tuples of `in` in which the first value matches `match`.
2. Retrieve the tuples that satisfy the `match` criteria and sequentially place them in `out`. If there aren't any matching tuples left, the subsequent slots in `out` should be filled with 0-padded tuples.
[For a deeper dive into component design, refer to the in-line comments](https://gist.github.com/enricobottazzi/1687b3393262984ed9c46f8146e5ae90)
### Task 1
In order to retrieve the indexes of the tuples `in` whose first entry matches `match` we design a circuit component `FindMatchingIndexes`.
This component takes as input an array `in` that contains only the first element of the tuples and `match`.
The role of the component is to return an array of binary values that indicates whether at that specific index the matching condition is satisfied or not.
### Task 2
The next step is to find the matching tuples and sequentially assign it to `out`. When there are no longer matching tuples pad `out` with 0.
In order to do so we design a circuit template `PerformAssignmentCycle`.
Note that this cycle has to performed once for each element in the `in` array.
The role of the component is to find the first available tuple that satisfied the matching condition and hasn't been already added to `out`. If such tuple was found, return it (and add it to `out`). If no such tuple was found, return a 0-padded tuple *(and add it to `out`).