The 29 June quiz asked you to figure out the text that would be displayed on the screen when this block was executed:
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.
and
This quiz is wrong. I tested it both on 10.2.0.4 and 11.2.0.1 Both returned the answer that I gave. It output both: TESTS: ef TESTS: ab Here is the script I used: BEGIN DBMS_OUTPUT.PUT_LINE('TESTS: '||SUBSTR('abcdefg',5,2)); DBMS_OUTPUT.PUT_LINE('TESTS: '||SUBSTR('abcdefg',-7,2)); END; This isn't the first time where I have found issues in the daily quizzes.
Finally, one of our most active (and consistently high ranking) players wrote to us as follows:
"Darn you :) I got this one wrong, because I misread the string as "abcdefg", not 'abdefg'. Just teaches us to read carefully - these sorts of typos happen in real code too. It's a good quiz."
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?