int box = 5;

Wednesday, September 20, 2006

Competition Programming: The Price is Wrong

Tonight was going to the "hard" problem set day. I was doing individuals and had a problem set of 4 problems. I decided that a simple expression parsing and evaluating problem was the easiest, followed by a Plinko odds simulator, then a 3D geometry problem, and then a scheduling problem.

I thought I understood the expression tree problem, but the way I approached it was a mess, so I redid it being more precise to the problem specs, and my test input worked. I submitted, but my output was apparently incorrect. After about 20 minutes of looking through my code, I knew I wouldn't be able to find whatever the error was on my own. So with about 45 minutes left, I ditched it and went to the Plinko problem.

I ended up wasting a lot of time by accidently switching my dimensions of my array for the Plinko board and messing up my arithmetical expressions. With 5 minutes to go (10-15 if I hadn't been a moron), I tested and my odds (expressed as percentages) were off by 1. Roundoff error, gah! Having no idea how to fix that, I submitted. Didn't get that one either.

So I submitted 5 times and got 0 problems in 2.5 hours. Looking at the scoreboard, only two other people doing individuals scored one problem (the expression problem). I think I wasted a lot of time by not planning out what I was going to do, because it's easier to write good code by hand (and then typing up) than first on a computer. I could have found whatever messed up my expression tree, and then wrote a lengthier but more accurate way to expression fractions in the Plinko program. I do think I ordered the problems correctly, though. The geometry question would also have given me headaches with floating points, and the scheduling problem would have been a nightmare since I have forgotten all dynamic programming techniques pretty much.

So I don't think I have impressed anyone in the past two weeks of this class, which really upsets me. Hopefully I will just figure it out one week.