+ 5
[SOLVED] Security problem...
You are in charge of security at a casino, and there is a thief who is trying to steal the casino's money! Look over the security diagrams to make sure that you always have a guard between the thief and the money! There is one money location, one thief, and any number of guards on each floor of the casino. Task: Evaluate a given floor of the casino to determine if there is a guard between the money and the thief, if there is not, you will sound an alarm. My Solution: n = input() c = "" for i in n: if i != 'x': c = c + i a = c.index("G") b = c.index("
quot;) c = c.index("T") if b >= a and c >= b: print("quiet") elif a < b: print("ALARM") elif b < a and b < c: print("quiet") else: print("ALARM") #Unable to pass only one test case :(15 Réponses
+ 8
#I think, this works..
#Observe the condition for guard just..
n = input()
c = ""
for i in n:
if i != 'x':
c = c + i
a=0
for i in c:
if i == 'G':
a = a + 1
#a = c.index("G")
b = c.index("quot;)
c = c.index("T")
if (b>a>c) or (b<a<c): #a between b and c(, guard between $ and T
print("quiet")
else:
print("ALARM")
#may this can be simplified in many ways in python.. but to understand problem, these steps clear that I hope.
**never give up in trying to solve anything..
hope it helps....
+ 7
ANOTHER IDEA
REMOVE UNNECESSARY X AND CHECK IF THIEF IS BESIDE MONEY OR NOT
a=input().replace('x','')
if a.index('T') in [a.index('#x27;)+1,a.index('#x27;)-1]:
print('ALARM')
else:
print('quiet')
+ 7
x = ''.join(input().split('x'))
y = ''.join(x.split('T#x27;))
z = ''.join(y.split('$T'))
print('ALARM'if '#x27; 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
+ 5
I think this code works try it
If it does not work let me know
https://code.sololearn.com/c8l9l340NC6x
Keep learning & happy coding :D
+ 4
I mean, For input G$T, it should output Alarm but your code , it's quiet.
+ 3
$GT is failing case there...
+ 3
Now only one case is failing...
+ 3
Now it's failing the case G$T
Note: There may be more than one guard also..
+ 3
That case is thr already :(
case 3 is failing for me
+ 3
If possible cn u send the code pls
I tried all the ways...
+ 2
Yo try this
setup = input()
setup = setup.replace('x', '')
S=setup.find('#x27;)
T=setup.find('T')
if ((T - S) == 1) or ((T - S) ==-1):
print('ALARM')
else:
print('quiet')
+ 2
cam= input().replace('x','')
x=cam.find('T')
y= cam.find('#x27;)
if abs((x-y))==1:
print ('ALARM')
else :
print('quiet')
+ 1
i = list(input())
x = []
for r in range(len(i)):
if i[r] != "x":
x.append(i[r])
z = "".join(x)
if "$T" in z or "Tquot; in z:
print("ALARM")
else:
print("quiet")
or:
i = input().replace("x", "")
if "$T" in i or "Tquot; in i:
print("ALARM")
else:
print("quiet")
+ 1
#Swift #swift
var myString = readLine() ?? ")"
var th = 0
var mn = 0
var gt = 0
for i in myString{
if i=="quot;{mn+=1}
else if i=="G"{mn=0; th=0}
else if i=="T"{th+=1}
if th>=1 && mn>=1{
print("ALARM"); gt+=1; break
}
};if gt == 0{print("quiet")}
- 1
a=input().replace("x","")
thief=a.index("T")
money=a.index("quot;)
range1=a[thief:money]
range2= a[money:thief]
if "G" in (range1 or range2):
print ("quiet")
else : print ("ALARM")