+ 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: break11 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
+ 1
For this input
xxxxxGxx$xGxT
your code deliver ALARM and this is wrong. Try to solve this.
+ 1
Stephen Norton Nah, I didn't solved it after that.
+ 1
Would you like to see mine?
+ 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.
+ 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
+ 1
That's awesome brother. Keep up the good work. It's fun.
0
Did you ever solve this problem? I found interesting solution if youre interested
0
Sure.
0
Stephen Norton Now that the difference between my code and an experienced guy's code lmao... Thanks, I'll test this one now.
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...