5.2.2 barbershop solution