+ 2

Why does the test case 3,4 and 6 is not working??

n = input() a = n.index("G") b = n.index("

quot;) c = n.index("T") if b >= a and c >= b: print("quiet") else: print("ALARM") Question is: 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. Output Format: A string that says 'ALARM' if the money is in danger or 'quiet' if the money is safe.

1st Jul 2021, 8:41 AM
Shahir
Shahir - avatar
4 ответов
+ 4
Shaik.Shahir , the if condition used in the code is not sufficient to get all possible combinations of "
quot; "G" "T" correctly in the way it is done. only "$GT" or "TG
quot; can give "quiet", all the others should give "ALARM". (there a 6 combinations possible in total) what makes it a little bit confusing are all the "x'. it could be helpful to remove all the "x" before checking the conditions. after this, only 3 characters are left,, which are easy to check. happy coding!
1st Jul 2021, 9:30 AM
Lothar
Lothar - avatar
+ 1
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. 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
1st Jul 2021, 8:53 AM
Shahir
Shahir - avatar
0
Thanks
1st Jul 2021, 9:32 AM
Shahir
Shahir - avatar
0
If you want faster results in games like Mines or Gems, auto mode is a game-changer. I was hesitant at first, but it actually made my gameplay smoother and more efficient. https://biblicaltribe.com/how-to-use-auto-mode-in-mines-and-gems-on-1xbet-for-fast-results/ offers a simple guide on using auto mode effectively in 1xbet. Once I started using it, my win/loss tracking improved significantly. It’s great for players who prefer strategy with a touch of automation.
30th Jun 2025, 10:12 PM
annastivenson