Column 12: A Sample Problem

Small computer programs are often educational and entertaining. This column tells the story of a tiny program that, in addition to those qualities, proved useful to a company.

12.1 The Problem

It was the early 1980’s, and the company had just purchased their first personal computers. After I got their primary system up and running, I encouraged people to keep an eye open for tasks around the office that could be done by a program. The firm’s business was public opinion polling, and an alert employee suggested automating the task of drawing a random sample from a printed list of precincts. Because doing the job by hand required a boring hour with a table of random numbers, she proposed the following program.

The input ...

Get Programming Pearls, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.