Ignore This Advice

Take My Advice

When you’re stuck on a programming problem for a while (everyone has their own time threshold), it’s customary to look for a hint. If you’re working on a competitive programming problem from a past contest, they’re easy to find. Problems on uHunt are categorized by algorithm, so that’s a big hint already. Popular problems often have editorials (I have written a few myself) or even complete source code in multiple programming languages. On the other hand, if your problem has to do with a programming language or tool rather than a puzzle, Stack Overflow is the standard resource.

But what if your problem is more general than a programming puzzle or language quirk? What if you have the type of question that gets closed on Stack Overflow? In other words, what if you’re looking for advice.

« Continue »

Java Lessons from uHunt Chapter 1


This post is part of a series on Java syntax and libraries for solving the problems in each chapter of uHunt, a tool for competitive programming practice. You can find the rest of the posts in the series by visiting my uHunt Java post category.

A few months ago, I wrote two posts related to uHunt Chapter 1. The first post covers general lessons learned from completing the 39 starred problems in that chapter. The second one is a summary of the corresponding chapter of Competitive Programming 3, the companion textbook. Although I have covered Java language features in those and other posts, I thought it would be useful to provide an overall summary of the parts of Java that I found useful when solving the problems in that chapter.

« Continue »

Profiling Java Programs with VisualVM


Last week, I wrote about ways to improve runtime performance for a Java solution to UVa 732. This week I’m going to cover a process for analyzing Java program performance using the profiling features of the VisualVM Java troubleshooting tool. But first, a note about profiling. As I mentioned last week, even a highly optimized program can fail to be accepted by an online judge if it uses the wrong algorithm. In other words, you generally can’t profile your way out of a slow design. Nevertheless, looking at a VisualVM snapshot of your implementation can provide some useful performance insights. Just don’t spin your wheels for too long making tiny adjustments to your implementation. You may need to go with a different design instead.

« Continue »

Implementing a Fast Solution to UVa 732

Stone Stack

Programming puzzles are often designed in such a way that getting your solution to complete under the time limit is at least as challenging as getting the correct result. To create such a challenge, a problem setter can adjust the size of the input until sub-optimal solutions no longer run in under the time limit.

Many puzzles can be solved using both a slower but easier approach and a more sophisticated method that runs within the required time limit. Among the uHunt starred problems, 732: Anagrams by Stack is one in which people have found performance particularly challenging, at least based on the forum threads. As with previous anagram problems, and performance-sensitive problems in general, getting Java to perform at the required level can be especially difficult. While some online judges provide wiggle room for languages with more overhead than C/C++, UVa Online Judge doesn’t seem to use that policy.

« Continue »

The Problem With Codecademy

Academy of Athens

I believe in the importance of practicing programming fundamentals, especially through programming puzzles. But puzzle learning works best when you already have some experience with the programming language you’re using to solve them. By prompting you to exercise a core set of programming fundamentals, puzzles help strengthen basic coding skills. To get those basic skills in the first place, you need a starting point for learning. For a few years now, coding instruction in the browser has been a convenient option.

« Continue »