+ 1

Security problem in Python.

Hey guys, I was trying to solve this question but seems like the compiler reads my code in wrong way. I think I've done right. Out of 5 tests it qualifies in 4 only fails the first test which I think it shouldn't as I checked it. Here is the question: https://www.sololearn.com/coach/77?ref=app Pls let me know what in my code is wrong. Thank you. And here is the code that I wrote: floor=input() count=0 for i in range(len(floor)): if floor[i]=='x': continue elif floor[i]=='

#x27; or floor[i]=='T': if count==1: print('ALARM') break else: count+=1 elif floor[i]=='G': if count==1: print('quiet') break else: print('ALARM') break else: break

27th May 2021, 12:58 PM
Prakhar
Prakhar - avatar
11 Réponses
+ 1
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
15th Dec 2021, 2:56 PM
Stephen Norton
Stephen Norton - avatar
+ 1
For this input xxxxxGxx$xGxT your code deliver ALARM and this is wrong. Try to solve this.
27th May 2021, 1:28 PM
JaScript
JaScript - avatar
+ 1
Stephen Norton Nah, I didn't solved it after that.
15th Dec 2021, 2:55 PM
Prakhar
Prakhar - avatar
+ 1
Would you like to see mine?
15th Dec 2021, 2:56 PM
Stephen Norton
Stephen Norton - avatar
+ 1
It took me a while and I tried other way more complicated leads. But often I have to scrap those leads because it's simpler than I had originally thought. This is one of those times. I like the way it came out.
15th Dec 2021, 2:59 PM
Stephen Norton
Stephen Norton - avatar
+ 1
I actually just started coding 2 months ago. But for many years I taught myself math and logic and I love them both. So, it helps me a lot with the problem solving. But experienced - not even close. I don't even know how to use classes and stuff. That may even be why my code is simpler. Lol
15th Dec 2021, 3:02 PM
Stephen Norton
Stephen Norton - avatar
+ 1
That's awesome brother. Keep up the good work. It's fun.
15th Dec 2021, 3:04 PM
Stephen Norton
Stephen Norton - avatar
0
Did you ever solve this problem? I found interesting solution if youre interested
15th Dec 2021, 2:52 PM
Stephen Norton
Stephen Norton - avatar
0
Sure.
15th Dec 2021, 2:56 PM
Prakhar
Prakhar - avatar
0
Stephen Norton Now that the difference between my code and an experienced guy's code lmao... Thanks, I'll test this one now.
15th Dec 2021, 2:58 PM
Prakhar
Prakhar - avatar
0
I've been away from coding stuffs for a while now but I'm trying to start Python from scratch now... Have an IT exam next year...
15th Dec 2021, 3:03 PM
Prakhar
Prakhar - avatar