html SOJ Algorithm: Sock Nerd Problem

Problem Statement

You have 12 socks: 4 pairs of identical socks, and 8 identical socks of another type. How do you pair up the socks so that each sock is paired with another sock of the same type?

Hint: Think like a Sock Nerd!

Example Solution

Sock Paring Algorithm

This solution involves sorting the socks by type, and then pairing up the socks of the same type. But wait, what about the 8 identical socks? Ah, those are easy! You just pair them up with... themselves!