Solving UVa 978 With Unit Tests

Last week, I wrote about how unit testing can improve your competitive programming practice. As promised, this week I’m going to go through an example of the unit testing process. For an example problem, I’ll be using UVa 978: Lemmings Battle! See above for a picture of a ferocious lemming. Problem Summary Lemmings Battle! is […]

Continue

Unit Testing Your Competitive Programming Solutions

A couple of months ago, I wrote an article about a type of unit test called a learning test. The goal of learning tests is improving your understanding of how code works, rather than verifying functionality or influencing design, the traditional goals of unit testing. This week, I’m going to discuss those traditional goals of […]

Continue

UVa 11572: Unique Snowflakes

UVa 11572 contains a story about a magic snowflake-capturing machine, but the underlying puzzle can be stated quite simply: Given a sequence of integers, find the length of the longest contiguous subsequence containing no repeated elements. The sequence given in the sample input is: 1, 2, 3, 2, 1 The subsequence 1, 2, 3, 2 […]

Continue

Summer Review

It’s summertime here in the Pacific Northwest, and seven months into the first year of this blog. After thirty weekly posts, I thought it would be a good time to consider the themes that have come up so far this year. If you’re a new reader, I hope you’ll find this to be a useful […]

Continue

Ignore This 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 […]

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 […]

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 […]

Continue

Implementing a Fast Solution to UVa 732

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. […]

Continue