Lab 8: Competition Problems

The Deadline for this lab is Friday, 14 Oct. 2016 as usual, the PDF file is erroneous.

Problems from the Berkeley Programming Contest

This week's lab consists of these three programming problems from the annual Berkeley programming contest, just as a break from our usual boring lab stuff. We've used these contests to select teams for the annual ACM Collegiate Programming Contest. In the Berkeley contests, participants work alone. In the ACM competitions, they work in teams of three (with one terminal between them). Feel free to do it either way (but eveeryone please submit a solution, even if it is collaborative, being careful, as always to name your fellow solvers).

In the contest finals, teams try to solve collections of these problems (13 in the 2015 contest, held in Marrakech, Morocco) in a period of 5 hours. Top contenders get very good at it (the Tokyo University team solved its problem in 2015 in 5 minutes!). No, we don't expect this of you, but take it as an indication that the problems are doable.

The skeleton files (,, and are very skeletal indeed this time. Input to each program will come from the standard input ( and output goes to the standard output.

The directories 1, 2, and 3 contain test data and expected results, which make check will use to test your solutions.