There are lots of cool pattern matching algos out there.  But the ones I looked at all seem to have have a catch: their worst-case behavior on small inputs is no faster than brute force, while being significantly more complicated in concept.  So I committed early on to a brute-force approach.  

The other simplifying decision I made was to select an algorithm that is ignorant of element identities.  It never determines exactly *which* elements are in the needle; it only detects if the current needle element is the same as the current haystack element, whatever that might be.  This saves rather a lot of preprocessing cost and mechanical complexity, but at a significant cost of execution speed--as much as an order of magnitude.

The one clever aspect of this algorithm is that it does not do single-character comparison.  Because every glyph consumption event requires a costly reset of the comparator elements, I set out to reduce as far as possible the number of consumption events and resets.  To do so, this machine divides the haystack into 4 trigrams (with the 2 inner ones generated via duplication).  It tests all 3 atoms in a trigram without resetting, and if any of the pairs is consumed by the comparator, it means the needle did not match.  Only in between trigrams does the comparator reset.  Thus, while single-character brute-force comparison would require 12 resets per haystack in the worst case, this machine needs only 4 in all cases.

Fun fact: this algorithm is so glacially slow that adding the parallel processor on the left side of the machine saved 600 metric.  I expect that this is much too slow to be competitive, but it is good enough for me. 

*********

Individually, the machine components are pretty straightforward.  

Uni glyph comparators are served by 3 hex arms, to shuffle permutations of atoms as painlessly as possible. Testing elements are provided by single-use setup machinery. 

Whenever a needle/haystack pair is not consumed by a comparator loop, one of its atoms is added to a stick.  If that stick is length 3 at the end of a trigram test, it wands gold into the output machinery before being chopped up and disposed.  

To reset a comparator, the final needle/haystack pair (if still present) is moved aside, and the 4 testing elements (if all still present) are unified.  This will create a quintessence, which is dispersed as quickly as possible.  The dispersed elements become the new testing element set, and are and placed back into the comparator hex arms.  If any of the input pairs *did* consume, there will be quint on the unification glyph already, so the dispersion task works as before.  But the 2 remaining testing elements will not consume during the reset, and are conditionally disposed.

Happily, this machine is clean and tidy, disposing of all waste atoms in an orderly(ish) fashion.  

PS: check out my entry for the "Most Ridiculous but Necessary Track Shape" contest!