+ 3

Code Coach Security

import re inp = input() no_gaurd = re.match(r'T\$|\$T|\$x*T|Tx*\

#x27;, inp) print('ALARM') if no_gaurd else print('quiet') Test 4 which should be ALARM doesn't get matched. Any suggestions?

29th Jan 2020, 1:42 AM
Onuoha_ifeanyi
Onuoha_ifeanyi - avatar
13 Answers
+ 21
s = input() m, t = s.find("
quot;), s.find("T") x = s[t:m] if m > t else s[m:t] print("quiet" if "G" in x else "ALARM")
29th Jan 2020, 6:20 AM
David Ashton
David Ashton - avatar
+ 10
inp = input() T, M = (inp.find('T'), inp.find('
#x27;)) if 'G' in inp[T:M] or 'G' in inp[M:T]: print('quiet') else: print('ALARM') Took a different approach thanks
29th Jan 2020, 2:55 AM
Onuoha_ifeanyi
Onuoha_ifeanyi - avatar
+ 9
layout=input().replace("x","") print("ALARM" if "T
quot; in layout or "$T" in layout else "quiet")
29th Mar 2020, 6:43 PM
Juan Rodrigues
Juan Rodrigues - avatar
+ 5
Check out 👇 s=input() a=0 for i in range(len(s)-1): if s[i] =='
#x27;or s[i]=='T': for j in range(i+1,len(s)): if s[j]=='G': a=1 break elif s[j]=='T' or s[j]=='
#x27;: a=2 break if a==1: print ("quiet") break elif a==2: print("ALARM") break
23rd Jul 2021, 3:19 PM
Tharul Nejana
Tharul Nejana - avatar
+ 3
Use that, it may help u, but in CSharp https://code.sololearn.com/c7VAUC96mU4N/?ref=app
20th Oct 2020, 5:44 AM
アデルモハメッド
アデルモハメッド - avatar
+ 2
str = list(input()) if "G" in str[str.index("T"):str.index("
quot;)] or str[str.index("
quot;):str.index("T")]: print ("quiet") else : print ("ALARM")
7th Dec 2021, 7:10 PM
Mas'ud Saleh
Mas'ud Saleh - avatar
+ 1
def find_caps(x): return [l for l in x if l.isupper() or l == '
#x27;] #cut upper letter and $ string = input() # 'TxxxxxGxx$xxx' check = ''.join(find_caps(string)) # join new string whis upper letter only if check.find('$T') == -1 and check.find('T
#x27;) == -1: # check this out print('quiet') else: print('ALARM') # PROFIT :)
1st Nov 2021, 8:41 PM
Johny Bracker
Johny Bracker - avatar
0
thought this was cheeky def solution(casino): thief = False money = False guard = False for x in casino: if x == "
quot;: money = True if thief and not guard: return "ALARM" guard = False if x == "T": thief = True if money and not guard: return "ALARM" guard = False if x == "G": guard = True if thief: thief = False return "quiet" if __name__ == "__main__": casino = input() print(solution(casino))
20th Apr 2020, 3:33 AM
shawn
shawn  - avatar
0
x = ''.join(input().split('x')) y = ''.join(x.split('T
#x27;)) z = ''.join(y.split('$T')) print('ALARM'if '
#x27; not in z else 'quiet') Noob style: passes all tests. #x removes space. #y&z remove only the thieves with money #If money is gone an alarm #else - it's all quiet
15th Dec 2021, 2:48 PM
Stephen Norton
Stephen Norton - avatar
0
Try this ☺️☺️ #include<stdio.h> int main() { char ch[100]; int i,f=1,j; gets(ch); for(i=0; ch[i]!='T'; i++); for(j=i; j>=0; j--) { if(ch[j]=='
#x27;) { f=0; break; } if(ch[j]=='G') { f=1; break; } } if(f==1) { for(j=i; ch[j]!=0; j++) { if(ch[j]=='
#x27;) { f=0; break; } if(ch[j]=='G') { f=1; break; } } } if(f==1) printf("quite"); else printf("ALARM"); return 0; }
13th Apr 2022, 9:10 AM
Deepak Rawat
0
Ruby solution word = gets.chomp.to_s word_new = word.gsub("x","") if((word_new.include? "T
quot;) ||( word_new.include? "$T")) puts 'ALARM' else puts 'quiet' end
13th Apr 2022, 8:31 PM
Seif Eddine N
Seif Eddine N - avatar
0
import re def security(code): if re.findall(r"(Tx*\$|\$x*T)", code): return "ALARM" else: return "quiet" print(security(input()))
18th May 2022, 7:36 AM
Dmitriy Panin
Dmitriy Panin - avatar
- 1
try re.findall
6th Sep 2020, 7:50 AM