01 July 2011

Q2 2011 ends; next playoff coming soon

Congratulations to all players for another busy, interesting quarter of quizzes and conversation at the PL/SQL Challenge.

As you've noticed, there was a lot of change at the website this past quarter, most importantly:
  • Release of a revamped version of the website
  • Kickoffs of SQL, APEX and Logic weekly quizzes
But through it all, over 2,600 Oracle technologists continued to take the daily quiz (not all of you every day, of course!). Such dedication!

Now it is time to run the last round of "too fast answer" analysis for Q2 submissions, and then come up with the participants in the Q2 playoff (by ranking, correctness and wildcard). We will publish the list next week.

And then, with our flexible and powerful platform, we will actually hold the playoff early in the next quarter, rather than towards its end. The only thing holding us back is....coming up with another set of fascinating, tough and not-too-tough quizzes for the playoff.

Perhaps that is how I will keep myself busy on our long 4th of July weekend.

Steven Feuerstein

30 June 2011

Leaving off "c" in "abdefg" a trick? (3571)

The 29 June quiz asked you to figure out the text that would be displayed on the screen when this block was executed:
   DBMS_OUTPUT.put_line ('-3,2='||SUBSTR ('abdefg', -3, 2));
   DBMS_OUTPUT.put_line ('-7,2='||SUBSTR ('abdefg', -7, 2));
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.


This quiz is wrong. I tested it both on and 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?