UMD Programming Contest:
- Wow today was horrible
- The enviroment they have set up for the programming contest makes it almost impossible to debug your code. They set System.out to output to a file, so if for whatever reason your program doesn't write the file, you have no way to find out why. I ran into a problem where my for loops were causing endless execution, but the program gave no indication of this. I checked in a normal java environment, and it turns out that the code:
int i = 0;
for (int j = 0; j < 5; i++)
System.out.print("");
does not give any compiler warnings, even though the compiler should be able to detect that this is extremely likely to be an unintended infinite loop. This is the first problem I ran into in my code, and it took me almost 45 minutes to discover the source since I wasn't able to print debug output!
I also just don't have a head for this sort of thing. The problem I'm currently working on is problem number 2 from the 2012 contest, which tasks you with identifying Pythagorean triples from an array of integers.
In my current strategy, I've got for loops nested three deep, one to identify each of the three numbers in the formula a2 + b2 = c2. There is probably a better way of finding triples, but I have no idea what it would be.
You will develop a "head for this" through lots of exposure to similar problems. That's why I'm so eager for you to get started now. It is a strange, unfamiliar world for you at this point, but the patterns you will learn through practice will soon make it much easier to solve similar problems.
ReplyDeleteI'm also counting on collaboration with Sam. Let's talk about this tomorrow.