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

0

Security code coach

I think i am missing smth but i don't know what it is. Case 6 doesn't work https://code.sololearn.com/cS38peY6gVp6/?ref=app

7/30/2020 6:26:20 PM

A. Essabbere

6 Answers

New Answer

+3

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

+1

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

0

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

0

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

0

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

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