Another Topcoder Challenge
Well, I did a little better this time around. For the longest time, I was actually in first place within my room. And then the system testing took me out (dropped me down a few positions).
Actually, I was a little careless in my unit testing and didn't test the simplest test that they provided. And wouldn't you know, that's what took me out.
The challenge problem dealt with parsing an English sentence and then translating it into some other language. So, a sample sentence might be "The dog jumps to the cat". In parsing this, my code needed to recognize that "The dog" was the subject, "jumps" was a present-tense verb, and "to the cat" was an objective preposition (or something like that) with "the cat" being the actual object. I would then have the components needed to perform the translation logic.
So, I tokenized the sentence into a string array, which worked fine. I then methodically determined the subject, verb, what kind of subject, the tense of the verb, etc. I also had code to handle the object, but this was optional data per the problem description.
At some point in the coding, I inserted a line of code to try to get the object by index number. In the above sentence, my code would do something like: obj=words[5] (and then obj would equal "cat").
Well, turns out that I inserted this line before my code that checked if there were more tokens (meaning, if there was an object). So, the test data was something like "Jason codes", and I was trying to perform: obj=words[2]. Since there's only 2 elements, index 2 (which would be the third element) is out of range.
Scoring is based on how quickly you submit a solution that compiles, so that's why I was pressured to not perform all example tests that they provided. I'm kicking myself now, because instead of losing another 10 points or so for the time that it would have taken me to run the last simple test, I lost 600 points (or so) for the entire problem.
BLAH! (kicking myself)
|