The uHunt Chapter 1 starred problems contain three examples of chess problems. In Chapter 3, we get back to chess with a variation on the classic eight queens puzzle. UVa 11085 is used to illustrate the algorithmic technique known as recursive backtracking.
When Not to Simulate a Game (UVa 11553)
Some programming puzzles can be solved by simulating a game or process. For example:
- UVa 978 is based on simulating a conflict between warring lemmings.
- For UVa 732, you have to simulate something more abstract: a stack that pushes and pops characters.
UVa 11553 may seem like a classic simulation problem: a board game between two players. But it soon becomes clear that this problem can’t be solved by simulating the players’ moves.
Command-Line Tools for Competitive Programming
When they select their tools, programmers have a choice between command-line and GUI options. Most people use both. For example, I prefer to use GUI tools for diffing a set of files I’m preparing to commit to a source repository. I also like my editor to be graphical, though I use a lot of keyboard shortcuts. But command-line tools are preferable when I’ll be repeating the same action multiple times. It’s a lot more efficient to retrieve a typed command from the shell history than to do the same steps repeatedly using mouse clicks or even keyboard shortcuts. Today I’ll be explaining some commands that are useful for programming puzzles.
Equation Solving is the Key to UVa 11236
UVa 11236: Grocery Store is an unusual problem for UVa Online Judge: it takes no input! There’s just a problem statement explaining the rules for finding the output. The lack of input and the mathematical nature of the problem reminds me of the problems on Project Euler. And as with Project Euler, you could cheat the time limit by calculating the output offline and just having your program print it. But if you would rather write a program to solve this problem quickly, keep reading for ideas.
A Git Workflow for Programming Puzzles
If you practice programming puzzles regularly, you probably keep an archive of your solutions. This can be useful for reference when you encounter similar problems. And even if you never look at some of them again, disk space is cheap and source code is small, so why not?
The simplest way to save your solutions is to put all of the files related to each solution (source code, input text, sample output text, etc.) in a directory on your local disk. I suggest going one step beyond that, and using a source control system to keep track of your solution files. These days, it makes sense to use Git.
Combinations and Permutations for UVa 735
Combinations and permutations are worth learning about for programming puzzles, and for programming in general. UVa 735: Dart-a-Mania provides a basic introduction.
Red-Green-Code: 2015 in Review
One year ago, I started writing here on the topic of deliberate practice techniques for software developers. This is my 52nd weekly post for 2015. With the year coming to an end, let’s review the story so far.
Math Fluency for UVa 927
From time to time, I’ll run across a UVa problem description that makes liberal use of mathematical notation. UVa 927, the first starred problem in uHunt Chapter 3, is one of those. uHunt classifies it as a Level 4 problem, but most of the challenge is in interpreting the problem description. Once you figure out what it’s asking for, the problem itself is straightforward.
The Competitive Programming Debate
Which of the following statements best describes your opinion of competitive programming?
-2
: It is harmful to the software industry, and should be abolished.-1
: It’s no worse than any other form of entertainment, but it has no educational value.0
: It may help some people get better at programming, but it’s a niche hobby.1
: It’s a good way to get better at programming. Every programmer should try it out a few times to see what they think.2
: It should be a required part of all college algorithms classes.
I’m not conducting a survey. These are just statements representing the range of opinions that I have seen while reading the Competitive Programming topic on Quora. (Actually I’m not sure if I have ever seen (2)).
As with any controversial topic, it’s common for people to talk past each other when discussing the pros and cons of competitive programming. In this post, my goal is to express the various arguments as clearly as I can.
That’s not to say that I am neutral on the matter. My opinion is closest to (1). I have written a post about reasons to study competitive programming, and of course much of the content on this blog deals with using competitive programming puzzles for learning. However, I’m always interested to hear differing opinions, especially when they have good arguments to back them up.
With that framework in mind, let’s take a look at what people are saying about competitive programming.
Java Lessons from uHunt Chapter 2
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.
In the previous post in this series, a review of Java for uHunt Chapter 1 problems, I covered Java basics. This time around, I’ll be discussing the additional Java features required to solve the Chapter 2 problems. The problems in this chaper focus on data structures, so we’ll be looking at data structures supported by the Java Class Library.
As before, I have put full examples of all of these topics in my Reference.java reference class. You can look there to find sample code to try out.