0
[Solved]"Security" challenge catching on last hidden input
The question is : find out if there is a 'G' in between a 'T' or '
#x27;. There is one $ and one T and random number of G's. There is also a random # of 'x' interspaced. If there is no G between T and $ print "ALARM" Else print "quiet" Example code: xxGxxT$ result: ALARM Ex2: xxxTGxx$xx Result: quiet This is my code: import re plan = input() pattern1 = r"^[x|G]*['#x27;]+[x]*[G]+[x]*[T]+[x|G]*quot; pattern2 = r"^[x|G]*[T]+[x]*[G]+[x]*['#x27;]+[x|G]*quot; if re.search(pattern1, plan) or re.search(pattern2, plan): print ("quiet") else: print("ALARM") In almost all situations it's printing the correct thing. I don't know why it's catching on the last thing. Thanks for any help.3 ответов
+ 1
Malek Alsset be careful with the *, it's gready
0
Thanks. I am gonna stare at your code until I understand it.
0
Ur code doesn't work