Echo -n "orange" | ./your_program.sh -E "[^opq]" test report shows expected exit code is 0

I’m stuck on Stage #RK3.

Here are my logs:

remote: [compile] Moved ./.codecrafters/run.sh → ./your_program.sh
remote: [compile] Compilation successful.
remote:
remote: [tester::#RK3] Running tests for Stage #RK3 (Negative Character Groups)
remote: [tester::#RK3] $ echo -n "apple" | ./your_program.sh -E "[^xyz]"
remote: [your_program] /app/app/main.py:11: SyntaxWarning: invalid escape sequence '\d'
remote: [your_program]   if(pattern == "\d"):
remote: [your_program] /app/app/main.py:14: SyntaxWarning: invalid escape sequence '\w'
remote: [your_program]   elif pattern == "\w":
remote: [your_program] Logs from your program will appear here!
remote: [tester::#RK3] ✓ Received exit code 0.
remote: [tester::#RK3] $ echo -n "banana" | ./your_program.sh -E "[^anb]"
remote: [your_program] /app/app/main.py:11: SyntaxWarning: invalid escape sequence '\d'
remote: [your_program]   if(pattern == "\d"):
remote: [your_program] /app/app/main.py:14: SyntaxWarning: invalid escape sequence '\w'
remote: [your_program]   elif pattern == "\w":
remote: [your_program] Logs from your program will appear here!
remote: [tester::#RK3] ✓ Received exit code 1.
remote: [tester::#RK3] $ echo -n "orange" | ./your_program.sh -E "[^opq]"
remote: [your_program] /app/app/main.py:11: SyntaxWarning: invalid escape sequence '\d'
remote: [your_program]   if(pattern == "\d"):
remote: [your_program] /app/app/main.py:14: SyntaxWarning: invalid escape sequence '\w'
remote: [your_program]   elif pattern == "\w":
remote: [your_program] Logs from your program will appear here!
remote: [tester::#RK3] expected exit code 0, got 1

And here’s a snippet of my code:

 elif pattern.startswith("[^") and pattern.endswith("]"):
        for char in pattern[2:-2]:
            if char not in input_line:
                continue
            else:
                excludePattern = False
                break
                #print(char)
        return excludePattern

Hey @cicada-581, your code should check if any character from the input is not in the pattern, not the other way around.

You can try running this command:

  1. o is in opq, so we continue;
  2. But all of range is not in opq, so any of them can trigger a match.

Let me know if you’d like further clarification!

1 Like