algorithm – How to pair socks from a pile efficiently? – Stack Overflow