+ 15
It's a sign - why does this solution NOT fail?!
The description explicitly says that 4 strings are to be given, like this: CAT MONDAYS RACECAR TACOS And now look at my solution: words = [] for i in range(1): try: inp = input() if not inp: break except: break words.append(inp.strip()) print('Open' if any(word==word[::-1] for word in words) else 'Trash') Look at the range: The loop is executed just ONCE. The errorhandling would abort if something is wrong with the input. Now I should have only one word in the list. But I pass all the tests anyway. Anybody an idea what's going on here?
24 Respostas
+ 9
Could be an edge case that the first element in all the test cases reflect the expected answer of the entire group
SL should fix the test cases if that's true
The 3rd test case and above are hidden so can't verify this.
But the first and second conform to the theory 😯
+ 10
Waittttt a minute HonFu !!!
This passes:
word = input().replace("\r", "")
print('Open' if word==word[::-1] else 'Trash')
The input function sometimes adds \r for some reason
My theory still stands 🥳
+ 10
This is why we need randomized tests and not just 6 but 600 :D
+ 6
I just printed out 4 inputs:
They do give them.
Only... well, what Burey found.
+ 4
No need for blowing minds Saurabh Tiwari
It's the immediate logical explanation
Tho, more often than not in programming you can be surprised by the output, no matter how sure you are of the code 😅😅😅
+ 4
HonFu nice
That debunks my theory and shred it to pieces 😅😅
+ 4
This passes all cases
word = input().split()
print('Open' if word[0]==word[0][::-1] else 'Trash')
Burey's theory is still alive
+ 3
Burey 🤯🤯🤯
that's some real problem with the test cases if that is true
+ 3
✳AsterisK✳, why is it supposed to be a bad practice for tasks?
Logically, when an error situation is created by something you can't control (like when bad input is given), exception handling is exactly what would be used.
The tasks here generally give very limited information. Especially for C writers you are always left to guess: How large should I make my char arrays, how long will the input be?
There's a lot of tweaking to be done. If you only do five or six tests, they should be good tests.
+ 3
HonFu the thing is just that, the test cases will not go beyond what is said to be given, if the problem says write a program to sort 4 characters it ain't gonna be 5, that's kind of the rule, like they should not be a a constraint to guess if the input will be more than asked or less
+ 3
✳AsterisK✳, under normal circumstances you are right - but don't forget we're dealing with sloppy Sololearn here!
Have you read what this question is about?
They explicitly say 'take four inputs', and then they design the tests so randomly that you can pass even if you take only one input!
That's not the only case we've encountered:
In pig latin, people got failed tests because they removed punctuation. And yeah, right, they wrote in the description that we don't have to take care of that. But IF you care, you'll fail.
Which can only mean that they input punctuation at least once, although that makes no sense in the context.
Or look here:
https://www.sololearn.com/discuss/2104980/?ref=app
They demand you use ceil, but depending on how you write the code, you will fail with ceil and succeed with round.
So yeah, in a situation where there are a sufficient number of test cases and they are all well-designed, you should be able to get by without error-handling.
But this is not what we have here. ;-)
+ 3
yeah, i understand your point HonFu
+ 3
This works fine !!
https://code.sololearn.com/cLwP8O18X7E9/?ref=app
+ 3
I think the problem with test cases is that in some of the hidden cases the input (i.e. "sign text") is made up of two or more words. Thus, solutions using split() fail. The key is to take exactly 4 inputs. Of course this is particular to this problem and environment, where the SL editor takes inputs on several lines at once.
This one-liner works:
print('Open' if any(w == w[::-1] for w in [input(), input(), input(), input()]) else 'Trash')
+ 2
Should they seriously have designed their tests that sloppily?
I mean, that's almost random.
Or did they reconsider to one input and forgot to change the text?
+ 2
Nobody knows. It's like real live 😂
+ 2
HonFu i heard and i noticed that using an exception is a bad practice for the challenge and even in codewars its been given in description not to use exception handling, that might be a problem too
+ 1
Burey, I just tried this:
word = input()
print('Open' if word==word[::-1] else 'Trash')
If the only reason was that always the first input makes the difference, shouldn't I succeed with this version as well?
It fails some tests though.
+ 1
Just FYI:
_________________
_________________
_________________
https://code.sololearn.com/cIWXP6Vv67ts/#py