Step 2: Charlieplexing

Picture of Charlieplexing
Assuming the output pins are actually tri-state-able (active high,
active low, and high impedence (input)) it is also possible to share
the row and column drivers and control N*(N-1) LEDs with only N pins.
One pin is connected to common cathodes of a row of LEDs and driven
low, and the N-1 pins remaining are connected to the anodes and either
driven high to light that column, or left as inputs to leave the LED
off. Maxim calls this technique "Charlieplexing", and describes it in
(1); Microchip also mentions this in their document (2) (and
implements in on the PICKit 1 board as well.)

(1) "Charlieplexing - Reduced Pin-Count LED Display Multiplexing"

(2) "Tips 'n Tricks 8-pin FLASH PIC Microcontrollers"

(3) Charlieplexing LEDs- The theory An Instructable by rgbphil