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. Essabbere6 Answers
New AnswerCheck 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.
Btw. it would be much easier, if you were checking for the other cases (thief next to money only).
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
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message