BEGIN DBMS_OUTPUT.put_line ('-3,2='||SUBSTR ('abdefg', -3, 2)); DBMS_OUTPUT.put_line ('-7,2='||SUBSTR ('abdefg', -7, 2)); END; /A number of players were unhappy with this quiz. Here are some of the comments:
I would bet a lot of people got this wrong (like me) because they failed to realize you didn't have a "c" in your input string. If the input string included the "c" (i.e. "abcdefg") then the second one would have returned "-7,2,=ab". I don't mind the question being a little tricky, but that one seemed to be purposely misleading.
Finally, one of our most active (and consistently high ranking) players wrote to us as follows:
Well, I can tell you with complete certainty that there was no intention to make this a tricky question. In fact, I didn't even notice that I'd left "c" out of the string. Looking over the comments, though, I believe that it actually made the quiz better than it would have been if it had included the "c". Consider: a player took the time to write code to validate the results and didn't even notice that he or she used the wrong string in the test.
When we are testing and debugging our code, one of our biggest problems is making assumptions about the data or about the code we are examining. Unverified assumptions are real "killers." I have wasted so many hours debugging programs over the years and then discovering that the problem didn't lie in my algorithm, but in the lack (or presence) of some problematic data. Or I read the code carelessly, seeing a string or value of some sort and thought it was "X" when it was "Y".
Happens a lot, doesn't it?
We tend to see and hear what we want or expect to see and hear, not necessarily what is actually there.
So this quiz tested more than your understanding of SUBSTR. It tested your ability to read the code closely and not make assumptions. I am OK with that. How about you?