Repository navigation
Description
Observed behavior
In Log Line Shape Template (word-pattern, LeetCode 290), the built-in tests accept a solution that never checks whether the message has as many words as the template has letters. It passes 7/7, the same as a correct solution.
class Solution:
def matchesTokenTemplate(self, pattern: str, s: str) -> bool:
words = s.split(" ")
pairs = set(zip(pattern, words))
return len(pairs) == len(set(pattern)) == len(set(words))zip stops at the shorter sequence, so template letters past the last word are never compared. On ["abba", "dog cat cat"] it sees only a-dog, b-cat, b-cat, counts two letters, two words and two pairs, and returns true. The answer is false: the template has four letters and the message has three words, and Jim's clarification says a message with more or fewer words than the template has letters does not match. The only built-in case with a count mismatch, ["abba", "dog cat cat dog fish"], has an extra word that is also a new distinct word, so the distinct counts already disagree there and the tests cannot tell the two solutions apart. Since every language runs the same judge cases, the gap is not specific to Python.
Expected behavior
At least one built-in case has fewer words than the template has letters, such as ["abba", "dog cat cat"] expecting false, so this solution fails the tests. A correct solution still passes every case.
Reproduction
- Run CodeTrial at the revision below, start a Practice interview on Log Line Shape Template (Coding only, Editor), and keep Python.
- Paste the solution above and run the tests. Test results shows 7/7: every built-in case passes.
- Under "Add a case", enter
["abba", "dog cat cat"]as the input andfalseas the expected value, then run again. Under "Your cases" the new case fails withgot true.
CodeTrial version
codetrial 0.1.0 (dad7b6e), built from source. The judge for this problem is unchanged between dad7b6e and main at 9f9adee.
Environment
OS: Windows 11 with the server in WSL2
Browser: Chrome 157.0.8103.78
Language: Python
Interview loop: Coding only
Problem: Log Line Shape Template (LeetCode 290)
REACTO or STAR step: Test
Reconnect: None
Sanitized evidence
All 7 built-in cases pass, and the added case fails with got true:
I would like to fix this by adding that case to problem-bank/judges.json and regenerating the judges. Please assign it to me.
Public data confirmation
- I removed credentials, session tokens, candidate recordings, and personal interview content from this public report.
Activity
jserv commentedon Nov 16, 2026
@April-ying Confirmed on
main(9f9adee):problem-bank/judges.jsongiveslog-line-shape-templateseven cases, and the only word-count mismatch,word count mismatch(["abba", "dog cat cat dog fish"]), has an extra word that is also a new distinct word, so the distinct counts already disagree and azip-based solution passes it. Accepted as scoped: add a case with fewer words than the template has letters,["abba", "dog cat cat"]expectingfalse, toproblem-bank/judges.json, regenerate withpython3 scripts/gen-problems.pyasdocs/adding-a-problem.mddescribes, and check that a correct solution still passes every case. Open the pull request withClose #741.Fail word pattern solutions that skip the count
Fail word pattern solutions that skip the count
Fail word pattern answers ignoring count or order
Fail word pattern solutions the judge let pass
Fail word pattern solutions the judge let pass
Fail word pattern solutions the judge let pass
Fail word pattern solutions the judge let pass
Fail word pattern solutions the judge let pass
Fail word pattern solutions the judge let pass
Fail word pattern solutions the judge let pass