0

2 of 6 test cases are getting failed can anyone help me.

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. Input Format: A string of characters that includes $ (money), T (thief), and G (guard), that represents the layout of the casino floor. Space on the casino floor that is not occupied by either money, the thief, or a guard is represented by the character x. #code goes here. import re n = input() modified = re.sub('x',"", n) check = "$GT" or "TG

quot; for i in modified: if check in modified: print ("quiet") else: Print ("ALARM") break

27th Feb 2021, 11:22 AM
thandava krishna
thandava krishna - avatar
14 Answers
+ 1
# shorter, and should work if I correctly understand the problem: import re n = input() check = re.search(r'\$[^G]*T|T*[^G]\
#x27;,n) print ("ALARM" if check else "quiet") # reg exp pattern used here search for $, anything else G and T or converse
27th Feb 2021, 2:35 PM
visph
visph - avatar
0
Arsenic i couldn't understand your point can explain it clearly.
27th Feb 2021, 2:08 PM
thandava krishna
thandava krishna - avatar
0
no, your code assign result of ("$GT" or "TG
quot;) to variable 'check' comparison are done with == but == only check for full string match, while 'in' operator check for left string to be in right string... however, if tou want multiple conditions (and/or concatened), you must repeat the left hand side: if a == b or a == c: ...
27th Feb 2021, 2:11 PM
visph
visph - avatar
0
}security_test=input('') m=0 g=0 t=0 for x in range(len(security_test)) : if security_test [x]=='
#x27;: m=x elif security_test [x]=='T': t=x elif security_test [x]=='G': g=x if t>g and g>m: print('quiet') elif m>g and g>t: print('quiet') else: print ('ALARM')
25th Oct 2021, 9:29 PM
youssef
youssef - avatar
0
import re casino = 'T$xxxxxxxxGxx' mod = re.sub('x', '', casino) check, check2, check3 = '$GT', 'TG
#x27;, 'T$G' if (check not in mod or check2 not in mod) and (check in mod): print('quiet') else: print('ALARM')
3rd Feb 2022, 5:37 AM
CodeStory
CodeStory - avatar
0
Hey, man! Don't stress about those test cases—sometimes, code just needs a little extra love to flow right. Take a step back, breathe, and see if there’s a pattern you’re missing. It’ll all come together, like the universe intended. And if you need a break, why not check out this https://stockmarketgame.casino/ It's a fun way to shift your focus and chill out. Peace and happy coding!
28th Aug 2024, 12:54 PM
Mark Millin
Mark Millin - avatar
0
It seems like you're having trouble with two of your test cases. Without seeing the exact code, it’s hard to pinpoint the issue, but there are a few common reasons why test cases might fail. Double-check if your logic covers edge cases and whether your data inputs are properly validated. On a side note, if you’re looking for some excitement after debugging, check out the https://mostbets-sri-lanka.com/deposit/ website in Sri Lanka. They offer a variety of fast and secure deposit methods, from e-wallets to bank cards, which make the process seamless. The site also supports the local currency, making it even more convenient for Sri Lankan users. If you’re interested, they even offer a great first deposit bonus to get you started!
25th Sep 2024, 9:41 PM
praise
praise - avatar
- 1
"or" doesn't work the way you think it is. "$GT" or "TG
quot; is an expression which will always return value of "$GT" as, for non Boolean values, "or" operator returns first non false value ( for strings empty strings are false and rest are considered as true )
27th Feb 2021, 11:37 AM
Arsenic
Arsenic - avatar
- 1
And anyway I tried and got same result.
27th Feb 2021, 2:07 PM
thandava krishna
thandava krishna - avatar
- 1
And I'm posting the additional information about the problem which was already given. so, you can have a better understanding about it. Output Format: A string that says 'ALARM' if the money is in danger or 'quiet' if the money is safe. Sample Input: xxxxxGxx$xxxT Sample Output: ALARM
27th Feb 2021, 2:10 PM
thandava krishna
thandava krishna - avatar
- 2
replace: if check in modified: with this: if "$GT" in modified or "TG
quot; in modified:
27th Feb 2021, 11:53 AM
iDaN
iDaN - avatar
- 2
iDaN isn't that what my code means? I just assigned the condition to a variable. Won't it work the same way?
27th Feb 2021, 2:05 PM
thandava krishna
thandava krishna - avatar
- 2
I tried solving in my own way, you may find it simple: f=input() l=list(f) im= l.index('
#x27;) it=l.index('T') if im<it: l1=l[im:it] if 'G' in l1: print('quiet') else : print('ALARM') elif im>it: l1=l[it:im] if 'G' in l1: print('quiet') else : print('ALARM')
1st Jun 2021, 1:19 PM
Akshay
Akshay - avatar
- 2
For c# Aaaaaaaaaa using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sololearn { class Program { static void Main(string[] args) { string flor =Console.ReadLine(); Char[] sit = flor.ToCharArray(); int b=0,pol=0,dozd=0,alarm=0; List<int> police=new List<int>(); foreach (Char a in sit) { if (a=='
#x27;) { pol=b; } if (a=='T') { dozd=b; } if (a=='G') { police.Add(b); } b++; } foreach (int d in police) { if(pol>dozd) { if(d<pol && d> dozd) { alarm=1; }
19th Aug 2021, 8:44 PM
Namdar Vali
Namdar Vali - avatar