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
6 Respostas
+ 3
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
+ 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? "Tquot;) ||( word_new.include? "$T"))
puts 'ALARM'
else
puts 'quiet'
end