Judge: Proper Aho-Corasick implementation with trie construction, failure links via BFS, and output sets. Type hints and docstrings present throughout. Uses defaultdict and deque appropriately. Response truncated before failure link completion and test cases, but the architecture is correct and well-structured. The visible code shows proper understanding of the algorithm.
Write a Python implementation of the Aho-Corasick string matching algorithm. It should accept a list of pattern strings, build the automaton, and provide a `search(text)` method that returns all matches with their positions and which pattern matched. Include type hints, docstrings, and test cases that cover overlapping patterns.
9 models responded
Judge: Proper Aho-Corasick implementation with trie construction, BFS-based failure links, and output merging. Type hints and docstrings are present on public methods. Test cases cover overlapping patterns (the classic 'he/she/hers/his' example). However, the second test (_test_various) has a questionable approach of filtering expected results at runtime rather than asserting known-correct outputs, and _test_empty tests empty pattern which is an edge case the algorithm doesn't handle well. The output merging via list concatenation (+=) is correct but could accumulate duplicates in pathological cases.
Judge: Textbook Aho-Corasick structure with separate trie building, BFS failure links, and output links. Excellent type hints, comprehensive docstrings, and clean class structure with AhoCorasickNode and AhoCorasick classes. Response is truncated before we can see the search method and test cases, but the architecture and code quality visible are strong. The output_link concept shows understanding beyond basic implementations.
Judge: The implementation correctly builds a trie, constructs failure links via BFS, and merges output sets along failure links -- this is textbook Aho-Corasick. The search method correctly reports matches with positions. Good type hints and comprehensive docstrings. However, the response is truncated mid-method (search_unique is cut off), so we can't verify test cases covering overlapping patterns were included, which is a hard constraint. The algorithm quality of what's visible is strong.
Judge: Implements Aho-Corasick correctly with trie construction and BFS-based failure link building. Good type hints and docstrings. However, the response is truncated before the search method is complete and the required test cases covering overlapping patterns are missing.
Judge: Correct Aho-Corasick structure with proper goto/fail/output tables, Match dataclass, and BFS-based build. The algorithm design is textbook correct. Truncated during the _build method, so we can't verify the failure link construction or see the search method and test cases. Strong code quality (type hints, docstrings, dataclass).
Judge: Implements genuine Aho-Corasick with trie construction and failure links via BFS. Has type hints and docstrings. However, the response is truncated — the search function is incomplete and no test cases are visible, which means the hard constraint for test cases covering overlapping patterns is likely violated. The algorithm structure is correct (failure links propagation, output link merging) but the BFS initialization has a subtle issue: root's children should have fail=root, but the code starts BFS from root itself which could cause issues.
Judge: Response describes Aho-Corasick correctly (trie, failure links, output links, BFS construction) and starts coding with type hints and docstrings. However, the code is truncated after the ACNode class __repr__ method — no complete automaton builder, no search method, no test cases. The algorithmic understanding is solid but the deliverable is incomplete.
Judge: The implementation is fundamentally broken. The automaton construction logic is wrong -- it creates nested dicts incorrectly and doesn't build a proper trie, failure links, or output links. The response is truncated mid-function, cutting off in the _search method's docstring. No test cases are present at all. Has the <|python_tag|> artifact.