Security code coach | Sololearn: Learn to code for FREE!


Security code coach

I think i am missing smth but i don't know what it is. Case 6 doesn't work

7/30/2020 6:26:20 PM

A. Essabbere

6 Answers

New Answer


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


Therefore you would still have to allow multiple guards next to each other, what your code doesn't. It just allows * x as neighbors.


Test case 6 is a bunch of guards between the money and the thief...


Btw. it would be much easier, if you were checking for the other cases (thief next to money only).


I solved the problem . I just wanted to try out regex


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