Code Coach Security | Sololearn: Learn to code for FREE!


Code Coach Security

import re inp = input() no_gaurd = re.match(r'T\$|\$T|\$x*T|Tx*\$', inp) print('ALARM') if no_gaurd else print('quiet') Test 4 which should be ALARM doesn't get matched. Any suggestions?

1/29/2020 1:42:24 AM


13 Answers

New Answer


s = input() m, t = s.find("$"), s.find("T") x = s[t:m] if m > t else s[m:t] print("quiet" if "G" in x else "ALARM")


inp = input() T, M = (inp.find('T'), inp.find('$')) if 'G' in inp[T:M] or 'G' in inp[M:T]: print('quiet') else: print('ALARM') Took a different approach thanks


layout=input().replace("x","") print("ALARM" if "T$" in layout or "$T" in layout else "quiet")


Check out 👇 s=input() a=0 for i in range(len(s)-1): if s[i] =='$'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]=='$': a=2 break if a==1: print ("quiet") break elif a==2: print("ALARM") break


Use that, it may help u, but in CSharp


str = list(input()) if "G" in str[str.index("T"):str.index("$")] or str[str.index("$"):str.index("T")]: print ("quiet") else : print ("ALARM")


def find_caps(x): return [l for l in x if l.isupper() or l == '$'] #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$') == -1: # check this out print('quiet') else: print('ALARM') # PROFIT :)


thought this was cheeky def solution(casino): thief = False money = False guard = False for x in casino: if x == "$": 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))


x = ''.join(input().split('x')) y = ''.join(x.split('T$')) z = ''.join(y.split('$T')) print('ALARM'if '$' 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


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]=='$') { f=0; break; } if(ch[j]=='G') { f=1; break; } } if(f==1) { for(j=i; ch[j]!=0; j++) { if(ch[j]=='$') { f=0; break; } if(ch[j]=='G') { f=1; break; } } } if(f==1) printf("quite"); else printf("ALARM"); return 0; }


Ruby solution word = gets.chomp.to_s word_new = word.gsub("x","") if((word_new.include? "T$") ||( word_new.include? "$T")) puts 'ALARM' else puts 'quiet' end


import re def security(code): if re.findall(r"(Tx*\$|\$x*T)", code): return "ALARM" else: return "quiet" print(security(input()))


try re.findall