Developer

CNET engineer wins JavaOne Coding Challenge

Matthew McEachen, a senior software engineer based in CNET's San Francisco office, won the Coding Challenge at the recent JavaOne conference. He tells us a little about the challenge and shares his thoughts on programming in Java.

We always thought we worked with a bunch of smart people here at CNET, but now we have actual proof. Matthew McEachen, a senior software engineer based in our San Francisco office, won the Coding Challenge at the recent JavaOne conference. We got a few minutes from him recently to answer some questions about his accomplishment.

Q: Tell us a little bit about this Coding Challenge—what was the exact challenge?

A: In the coding phase, you get an hour to solve two problems. The first problem was 350 points, and involved querying a Web service to determine the closest restaurant to a given location with a certain set of menu choices.

The second question was 1,000 points, also a Web service problem. Given a 10-by-10 city grid, determine the fastest route between two points. The Web service would only provide the travel time to pass through a single requested city block. No one finished that problem.

After the hour of coding, there's the challenge phase where you get to look at your competitor's solutions. You can challenge their solution with some set of input you think will make their code break. If their code does indeed fail, you get 50 points and you uncover their flawed solution, so they get 0 points. If their code passes your challenge, you lose 50 points.

Q: What tools/references did you get to use?

A: You have to write your code directly into their TopCoder Arena Applet. You can paste code into their text area, but you can't copy out of it. They also give you a browser with unrestricted access to the Internet.

I normally code with IntelliJ IDEA and Emacs, but the computers at the competition were so slow that using either tool wasn't really an option. So I just typed straight into the text area.

Q: The score between you and the second-place guy looks pretty close. What was it about your program that earned it the extra points to win?

A: I submitted my solution faster than he did. Actually, the two guys that got zero points both finished faster than I did, but neither of their solutions passed the unit tests.

Q: The TopCoder site lists a number of possible grand prizes. Which one did you actually win?

A: Every day's winner got all of the grand prizes. It's certainly a lot of goodies!

Q: You're obviously good at Java, but do you actually like programming in Java or is there some other language you secretly prefer? Are you one of those closet PHP programmers?

A: Be suspicious of any programmer that says "language X is the best." No tool is applicable for every task.

I've done some PHP. For small one-off tasks, shell and Perl scripts can make a lot more sense than to wait for a JVM to spin up.For anything non-trivial, though, using Java opens up a very rich environment to get your work done. Modern IDEs, like IDEA, let you code at a much higher level than simple text editors—you worry about the interesting bits, and the tool automates the drudgery.

Q: Drunk with success, what's the next challenge you're looking to enter? Run a marathon? Climb Mount Everest?

A: Heh, sign me up for the marathon. But if I get to beta with my personal side project, PhotoStructure, I'll be just as happy.

Q: What advice would you have for anybody thinking of entering one of these flash-programming contests?

A: The TopCoder folks not only give really good questions, with tons of sample inputs and expected outputs, but they make it easy to run those inputs against your solution in their applet before you submit. Even if you think your solution is correct, at least run all of the canned tests. There is no partial-credit score if your solution is not completely correct.

Also, if you know your solution is not correct, don't bother submitting it on the off-chance the geek gods will smile upon you. Those gods are more than happy to spite you, and you risk a competitor challenging your solution. They get 50 points due to your excess optimism.

Editor's Picks

Free Newsletters, In your Inbox