A heavily-commented answer to the longest plateau assignment.