0
Unable to solve Test case #4 of problem named "Security" in hard section of code coach
I am using REGEX in this problem (personal preference). Can anyone identify exactly what my pattern is not recognising or where am I going wrong? from re import search pattern = r"(^G(x)*(\$)+(x)*T$)|(^T(x)*(\$)+(x)*G$)" if search(pattern, input()): print("ALARM") else: print("quiet")
3 Respostas
+ 1
Money doesn't have to be in middle,
consider two other cases, explicitly :
$_T_G
G_T_$
0
Still the fourth test case is failing. I added the above two conditions in the regex.
0
Because it doesn't have to begin with one of the three special characters and also does not have to end with one of the three special characters.
Instead of ^G, use "any character of any number exists or not exists", i. e. "^.*G.....
Same idea for handling the end.
Here is a reading about {n}, {a, b}, +, ? and *