0

Why i am sticking here ? This is the casino problem, hard

string = input( ) if "

quot; in string or "T" in string or "G" in string or "x" in string : if "
quot; not in string : print("quiet") elif "T" not in string : print("quiet") elif "G" not in string and "
quot; in string and "T" in string : print("ALARM") elif "
quot; not in string and "T" not in string and "G" not in string : print("quiet") if "
quot; in string and "T" in string and "G" in string : money_flor = string.index("
quot;) thif_flor = string.index("T") guard_flor = string.index("G") k = [ ] m = 0 for i in string : if i in k : guard_flor = m k.append(i) m += 1 for i in string : if i == "G" and string.index(i)>money_flor : guard_flor = string.index(i) if money_flor < guard_flor and guard_flor < thif_flor : print("quiet") elif money_flor > guard_flor and guard_flor > thif_flor : print("quiet") else : print("ALARM")

8th Jul 2021, 12:28 PM
UnTentetive
15 Respostas
+ 1
Amit Ranjan Sahoo good job! But... The problem tells you: Input: string containing one "
quot;, one "T", some "G" and some "x" You need to print("quiet") if there is a G is in beetwen $ and T else print("ALARM") I challenge you to rewrite the sentence above in python in less than, let's be generous, 15 (readable) lines If you have time, try doing it
8th Jul 2021, 3:00 PM
Angelo
Angelo - avatar
+ 5
Amit Ranjan Sahoo , i would suggest that you re-start a try with input() and getting the index from "G", "
quot; and "T". (as you already have done) with the 3 different elements we have, we could create 6 unique possible samples. but only 2 of them can give "quiet". "quiet" is only possible, when "G" is in the MIDDLE of the others. so these two are: $GT and TG$. these 2 are easy to check by the index you have already stored. for these 2 output "quiet", and for all the others output "ALARM" happy coding and good success!
8th Jul 2021, 2:26 PM
Lothar
Lothar - avatar
+ 5
Doug Warner , your post has no relation to the topic of this feed. this can be seen as spam. > maybe you wanted to modify your post. > otherwise it would be better if you start your own question, because the current discussion started one year ago. people may not be aware of your issue.
20th Apr 2023, 10:05 AM
Lothar
Lothar - avatar
+ 2
Come on! This should be python, you can even do it in less than 7 lines! I know you can do it! I'll give you a hint: Take the substring from $ to T (you don't need to check if they're in string, the problem says they'll be there)
8th Jul 2021, 1:16 PM
Angelo
Angelo - avatar
+ 2
You do that so good. I challenge you to solve this problem with more $ and T , print "Alarm" if there is at least 1 $ between T and G else print "quiet"
9th Jul 2021, 9:53 AM
TCorn
TCorn - avatar
+ 1
Angelo I did it but can't in 15 line but in 19 line of code 😀👍. Thank you for your challenge. I find the bug and did it in short❤️. Here it is 👇👇👇 string = input() m = 0 k = [ ] if "G" in string : gp = string.index("G") for i in string : if i in k : gp = m if i == "G" : k.append(i) m += 1 if gp < string.index("
quot;) and gp > string.index("T") : print("quiet") elif gp>string.index("
quot;) and gp<string.index("T") : print("quiet") else : print("ALARM") else : print("ALARM")
9th Jul 2021, 4:36 AM
UnTentetive
0
Angelo Bro yes,i found it in delay 😂,but i found 👍. Thnks for answering.
8th Jul 2021, 2:17 PM
UnTentetive
0
Great!
8th Jul 2021, 2:17 PM
Angelo
Angelo - avatar
0
Lothar I solved 👇 #number of floors string = input( ) #here thif is one and place where the money is one. #but number of guards are different, there can be one thif between two guards ! if "
quot;not in string or "T"not in string or "G" not in string or "x"not in string : if "G" in string and "
quot; in string and "T"not in string : print("quiet") if "
quot; not in string : print("ALARM") elif "G" not in string and "
quot; in string and "T" in string and "x"in string : print("ALARM") if "
quot; in string and "T" not in string and "G"not in string and "x" not in string : print("ALARM") if "
quot; in string and "T" in string and "G" in string : money_flor = string.index("
quot;) thif_flor = string.index("T") guard_flor = string.index("G") k = [ ] m = 0 for i in string : if i in k and "T" not in k : guard_flor = m k.append(i) m += 1 for i in string : if i == "G" and string.index(i)>money_flor : guard_flor = string.index(i) if money_flor < guard_flor and guard_flor < thif_flor :
8th Jul 2021, 2:30 PM
UnTentetive
0
Salam! https://aegee-baki.org/ saytında oynamağa başladığım zaman ardıcıl itkilər məni bir az narahat edirdi. Amma bir axşam, şans mənim tərəfimə keçdi və mən böyük bir məbləğ qazandım. Bu mənim üçün əsl sevinc anı idi və indi hər axşam bu saytda vaxt keçirirəm. Azərbaycanda belə keyfiyyətli və maraqlı bir platforma tapmaq çox xoş oldu. Həm oyunlar, həm də bonuslar çox maraqlıdır.
31st Aug 2024, 1:09 PM
Lazario Peepin
Lazario Peepin - avatar
0
Greetings! Interesting question and I understand why you might think that. On such platforms as Mostbet, there are always certain nuances that are worth staying for. One of the main points is the power-ups, which greatly enhance the overall experience of the game. For example, Mostbet often offers various promotions and bonuses https://mostbet-bangladesh.bet/bonus/ for new and regular players, which allows you to significantly increase your chances of success during the game. This really helps to feel more drive and get maximum pleasure from the game process.
25th Sep 2024, 4:49 PM
Paul Robertson
Paul Robertson - avatar
0
The excitement I feel when walking into a casino is like no other. The thrill of every bet, the chance to win big, and the energy in the room always keep me hooked. Lately, I’ve been exploring online options too, and I found https://argoldensands.com/dubai-casino/ It offers the same thrilling experience from the comfort of my home, and I can enjoy the fun anytime I want.
27th Sep 2024, 5:16 PM
Pol Slow
Pol Slow - avatar
0
Desde que descargué la app de Pin Up Casino, mi experiencia de juego https://pinupapuestas.cl/aplicacion/ ha cambiado por completo. La interfaz es súper intuitiva y me permite navegar fácilmente entre los diversos juegos, desde tragamonedas hasta juegos de mesa. Lo que más me impresiona son las promociones exclusivas para usuarios móviles; cada vez que inicio sesión, hay algo nuevo que aprovechar. Jugar en vivo con crupieres reales añade una emoción adicional que realmente me hace sentir en un casino físico. Si buscas diversión y variedad al alcance de tu mano, ¡no dudes en probar la app de Pin Up Casino!
28th Sep 2024, 10:38 PM
Victor Rogers