+ 4
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?
15 Réponses
+ 21
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")
+ 10
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
+ 10
layout=input().replace("x","")
print("ALARM" if "T$" in layout or "$T" in layout else "quiet")
+ 5
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
+ 3
Use that, it may help u, but in CSharp
https://code.sololearn.com/c7VAUC96mU4N/?ref=app
+ 2
str = list(input())
if "G" in str[str.index("T"):str.index("$")] or str[str.index("$"):str.index("T")]:
print ("quiet")
else :
print ("ALARM")
+ 1
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 :)
0
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))
0
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
0
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;
}
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
0
import re
def security(code):
if re.findall(r"(Tx*\$|\$x*T)", code):
return "ALARM"
else:
return "quiet"
print(security(input()))
0
s=input().replace("x","")
m,t = s.index('$'), s.index('T')
print("ALARM" if abs(m-t) ==1 else "quiet" )
0
aaa = input()
b = ''
for i in aaa:
if i != 'x':
b = b + i
if b.count('$T')<1 and b.count('T$')<1:
print('quiet')
else:
print('ALARM')
- 1
try re.findall